|
Thanks a lot ...
|
|
|
|
|
Guffa wrote: Because....
Don't you just hate repeating yourself.
|
|
|
|
|
sw.WriteLine("<body>"); <br />
sw.WriteLine("" + row["columnName1"]); sw.WriteLine("</body>")
The value columnName1 in this case is a static value. how can i make it dynamic? In my case, i have to give variable column names stored in an ArrayList.
sw.WriteLine("" + ArrayList[i]"]);
This gives an error in SQL that ArrayList doesn't match any column name in the database
|
|
|
|
|
Just replace the static string value with whatever you like:
sw.WriteLine("" + row[names[42]]);
Saira Tanwir wrote: sw.WriteLine("" + ArrayList[i]"]);
This gives an error in SQL that ArrayList doesn't match any column name in the database
Hardly. That code doesn't even compile...
---
Year happy = new Year(2007);
|
|
|
|
|
sw.WriteLine("" + row[names[42]]);<br />
I've already tried this. It doesn't work for me. Any other suggetions....??
|
|
|
|
|
No, there aren't any other suggestions, as that is how you do it.
If you want any help with the code that didn't work for you, you have to show it.
---
Year happy = new Year(2007);
|
|
|
|
|
You could iterate through the columns in the same way you do for the rows. Something like this:
sw.WriteLine("<body>");
foreach (DataRow row in myDataTable.Rows)
{
sw.Write("<p>");
foreach (DataColumn column in myDataTable.Columns)
{
sw.Write(row[column.ColumnName]);
sw.Write(" ");
}
sw.WriteLine()
}
sw.WriteLine("</body>");
|
|
|
|
|
Hi all,
I'm trying to track in intermittent exception that occurs in the code of some of my properties. What is the equivalent of
System.Reflection.MethodBase.GetCurrentMethod() for properties? I don't want to hard-code the property name in the catch section because there are a lot of properties in the solution. I'd rather use Reflection.
This is what I'm trying to do:
public bool Exists
{
get
{
try
{
// exception occurs here
}
catch(System.Exception ex)
{
ErrorLogger.Report(System.Reflection.MethodInfo.GetCurrentMethod(), ex); // Logs exception
}
return base.m_Exists;
}
}
Thanks in advance,
Vlad
|
|
|
|
|
use ex.TargetSite.Name property to get the name
public bool Exists<br />
{<br />
get<br />
{<br />
try<br />
{<br />
}<br />
catch(System.Exception ex)<br />
{<br />
ErrorLogger.Report( ex.TargetSite.Name,ex);
}<br />
return base.m_Exists;<br />
}<br />
}
|
|
|
|
|
hi every, one i have project which includes a windwos service and two windows apllication. the windos servcie have two dll files included.it all runs fine and every thing is ok but what i want to while making setup i want the dll files to be incuded in differnt folder and exe(executable) of windows service and windows application in one folder. and the confilg file of windows sevice in cofing folder how can i achle this with setup and deplyoment project of visula studio dot net 2003.
|
|
|
|
|
|
When I try to include a namespace in my programs, it comes up with an error, asking if I'm missing an assembly reference or something to that effect. I guess what I'm really asking is: How do I utilize namespaces in my programs?
---
A 13 Year Old Programming Wiz
The elementary kids were right!
"1" + "1' does = "11"!
|
|
|
|
|
You need to add a reference to the dll or application that holds the namespace. You should be able to right-click the project icon in the project explorer window and select Add Reference... then navigate to the dll whose namespace you wish to use. Then you will have access to the namespaces of the assembly and to use the namespaces, you can use the using namespace yaddaYadda;
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Thomas Stockwell wrote: Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Excellent quote...should be on a t-shirt somewhere.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
I'd like to generate C# front-end code automatically according to the database table structure, who can give me some guide how to do?
My thinking is just like:
In the database table 'Customers', there are one field 'Name' with the type 'VCHAR', one field 'ID' with the type 'LONG'. My program would generate the file 'CustomersView.cs' and 'CustomersView.Designer.cs' which contains one 'Label' of 'Name', one 'TextBox' of 'Name',one 'Label' of 'ID', one 'TextBox' of 'ID'.
Thanks in advance for you help.
|
|
|
|
|
As far as i know, you can generate the code dyanmically using ILEmit.. but i never tried that one.. Could u plz explain us, y do u need this funcnality.. insted. u could serialized the data store it in the database. and get it thru object and bind with front end controls.(winforms controls)
|
|
|
|
|
Thanks for your reply.
I'd like to generate a new WinForm class file according to known classes. For example, we already have an entiry class Customer, and I shall generate a form to show this business entity. The new form class is just what I want to automatically generate. I don't know if I made my thinking clear.
|
|
|
|
|
Rather than generating code automatically, you could come up with a form class that uses
reflection to display the relevant members of whatever object you give it.
Search CodeProject, MSDN, or Google, for reflection.
Luc Pattyn
|
|
|
|
|
I want to have 2 buttons. Push button 'A' and it prints to a network printer. Push button 'B' and it prints to a connected usb printer. Is there a way to specify a printer when printing WITHOUT popping up the print dialog?
thanks!
|
|
|
|
|
no... sorry... or can try some third party tools..
|
|
|
|
|
Hey, just brushing up on my regex in .NET. I used Stallman's lex/yacc back in the day (1990s) and made great programs with very little effort. Its seeming to me that MS in .NET has emphasized good lexical scanning but is short on building grammatical constructs a la YACC, short of laborious groupings (...). For instance, in YACC I could define a whole grammar for a language (for instance, a language that dictates chip layout) in about 1 page of code.
Is there something similar and as powerful with .NET Regex class? Maybe I'm overlooking something.
Thx.
|
|
|
|
|
I am trying to generate a system information as follows;
*********************************************************************
Process nfo = Process.Start("C:\\Program Files\\Common Files\\Microsoft Shared\\MSInfo\\MSInfo32.exe");
nfo.WaitForExit();
************************************************
Works fine but want to save it to a file, so tried this
*******************************************************
Process nfo = Process.Start("C:\\Program Files\\Common Files\\Microsoft Shared\\MSInfo\\MSInfo32.exe /nfo c:\\temp\\SysInfo.nfo);
*********************************************************************
bu does not work.
How can I run it with the arguments?
thanX in advanced
PC
|
|
|
|
|
You can pass arguments to the exe by calling
public static Process Start (string fileName, string arguments)
but this only helps for real arguments, not for the goodies offered by the DOS shell,
such as input and output redirection.
For these, you still need the Process class, but then you must set several of its
properties, and in order to do it correctly, you normally have to launch up to 3 extra
threads to take care of input, output and error streams.
I'm pretty sure either CodeProject (or Google) could offer you a reasonable example.
Luc Pattyn
|
|
|
|
|
thanX Luc,
the Process.Start(file,swtich) atually worked.
|
|
|
|
|
OK I searched google, msdn etc. but didn't find exactly what I need.
Can someone provide decent reference on this topic (hope detailed enough with best practice examples etc.).
Thanks!
|
|
|
|