|
And how can i do that ??
Can i have a code snnipet or link to such code depicting the same....
|
|
|
|
|
|
How to create many datatable dyanamically in c#.net. Thanks in Advance.
|
|
|
|
|
Can you be more specific to your Qs/requirement?
although at runtime time you can create datatable using DataTable class.Use google/msdn
Cheers!!
Brij
|
|
|
|
|
Brij wrote:
Brij wrote: I want to create datatabke array, where the array count will be statis and be declared in configuration. like .
int iCount=4;
for(x=1;x<=icount;x++)
{
// Here datatable object will be created dynamicall. like dt1,dt2.dt3....
DataTable dt+x =new DataTable();
// I want to add columns to the particular datatable.
dt+x.columns.add("NO");
dt+x.columns.add("NAME
..
}
Thanks.
|
|
|
|
|
Why don't you use List?Use list of Datatable.Here you don't need to worry about the size.Create datatable at runtime and add to the list.Whenever you need you iterate the list and use them accordingly.
Cheers!!
Brij
|
|
|
|
|
That's OK.But if I don't put the value in configuration then how would i know the count of datatables ???
|
|
|
|
|
You can get the count from the list itself.You can store it some session variable (if user specific) or application varaiable(if application specific) for any other use.
One thing How are you getting the count of the table.Is it coming at runtime?Can you be more specific to requirement?
Cheers!!
Brij
|
|
|
|
|
A windows service is supposed to launch an application, passing some arguments to the executable. I am trying to do this using CreateProcessWithLogonW(string principal,
string authority,
string password,
LogonFlags logonFlags,
string appName,
string cmdLine,
CreationFlags creationFlags,
IntPtr environmentBlock,
string currentDirectory,
ref StartupInfo startupInfo,
out ProcessInfo processInfo) API function.
I set the parameter "cmdLine" for passing string to the executable. The following code doesn't get me anything ...
static void Main(string[] args)
{
// that doesn't give any value
string acrossprocessvalue = args[0];
//neither the following lines
string test = Process.GetCurrentProcess().StartInfo.Arguments;
}
any help ...
fulbright
|
|
|
|
|
Process.Start will do it. Process class provides options to supply arguments too.
|
|
|
|
|
Thanks for the answer ... I started with Process.Start() actually but that wasn't fulfilling the requirements. e.g, The windows service is running under the "Network Service" user, a less privileged user,that wont be having the rights to display application on desktop, etc. So for such security tunnings I had to use CreateProcessWithLogonW() API function.
Madni
|
|
|
|
|
"cmdLine" argument that i'm trying to pass to CreateProcessWithLogonW() is a string basically but does it have some specific format ? I'm simple passing the value as
cmdLine = "testargument";
Is it OK ????
fulbright
|
|
|
|
|
Pass whatever you want, as long as the spawned app understands it.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi All ,
I downloded a sample project from internet it is using the following line .
public class BusinessCollectionBase<T> : ValidationCollectionBase<T> where T : ValidationBase
{
...........
some code here
...........
}
public abstract class ValidationBase
{
...........
some code here
...........
}
public abstract class ValidationCollectionBase<T> : Collection<T> where T : ValidationBase
{
...........
}
please anyone explain above line code (specially why we used <T> with where keyword) .
-------------------------
SANTOSH GAUTAM
-------------------------
|
|
|
|
|
T is the type and where is a constraint which will ensure T will be a type of ValidationBase . Read about generics[^]
|
|
|
|
|
hello froum
I am writing the elements to xml file on runtime,and also using them. It is working properly.
XmlDocument xmlDoc = new XmlDocument();
string path = AppDomain.CurrentDomain.BaseDirectory + @"\XMLFind.xml";
xmlDoc.Load(path);
XmlNodeList xmlNS = xmlDoc.GetElementsByTagName("testword");
The xml file is in the bin folder.
but the problem is after creating setup the xml file is visible to every body so it can be deleted accidently.
If the xml file is placed in the project then while using the output (after creating its setup) it gives the runtime error
Could not find the C:\Program Files\hts\SetupFinal\XMLFind.xml.
can anybody help me...
Regards
Rahul Adya
|
|
|
|
|
rahuladya wrote: but the problem is after creating setup the xml file is visible to every body so it can be deleted accidently.
There is no way to secure it. Just check the file existence before you read it and tell user if it is not available.
|
|
|
|
|
hello navneeth
Yes i know but the issue is not here, we can secure it by adding it to solution explorer and after creating setup it will not be visible to anybody.
The problem is how to find the xml file present in the project on runtime because the directory path will be changed after deployment.
Rahul adya
|
|
|
|
|
rahuladya wrote: because the directory path will be changed after deployment.
Place it in the application directory. Application.ExecutablePath will give you the current directory where application's exe resides.
|
|
|
|
|
hello froum
I am writing the elements to xml file on runtime,and also using them. It is working properly.
XmlDocument xmlDoc = new XmlDocument();
string path = AppDomain.CurrentDomain.BaseDirectory.Substring(0, AppDomain.CurrentDomain.BaseDirectory.LastIndexOf("bin\\")) + @"\XMLFind.xml";
xmlDoc.Load(path);
XmlNodeList xmlNS = xmlDoc.GetElementsByTagName("testword");
The xml file is in the bin folder.
but the problem is after creating setup the xml file is seen to every body so it can be deleted accidently.
If the xml file is placed in the project then it gives the runtime error
Could not fine the C:\Program Files\hts\SetupFinal\XMLFind.xml.
can anybody help me...
Regards
Rahul Adya
|
|
|
|
|
hello all
How to allow textbox to enter only alphabets using RegularExpression (Regex)
i have added the namespace
using System.Text.RegularExpressions;
Thanks
|
|
|
|
|
regex that allow only alphabets is below
^[a-zA-Z\S]+$.
You can validate the entered text in textbox by this.
Cheers!!
Brij
|
|
|
|
|
hello Brij
can u just show the code in 2 to 3 lines .....
|
|
|
|
|
|
Try handling the KeyDown event for the TextBox . If the character is one you don't want (a digit or punctuation for example), swallow it by setting e.Handled to true . That should work.
|
|
|
|