|
Use @"\"
e.g.
"C:\Program Files\Microsoft" <- wrong
@"C:\Program Files\Microsoft" <- OK
|
|
|
|
|
Hello,
How to save my DataTable, to my HD ?
If I written something like that :
// Create a DataTable.
DataTable table = new DataTable("Product");
// Create a DataColumn and set various properties.
DataColumn column = new DataColumn();
column.DataType = System.Type.GetType("System.Decimal");
column.AllowDBNull = false;
column.Caption = "Price";
column.ColumnName = "Price";
column.DefaultValue = 25;
// Add the column to the table.
table.Columns.Add(column);
// Add 10 rows and set values.
DataRow row;
for (int i = 0; i < 10; i++)
{
row = table.NewRow();
row["Price"] = i + 1;
// Be sure to add the new row to the
// DataRowCollection.
table.Rows.Add(row);
}
And now I want to save my DataTable, to my HD in the current directory with a name like "MyDataTable.mdb" ?
How I code it ?
Thanks.
Tintin92
|
|
|
|
|
Try this to save to XML on HDD:
//Instantiate DataSet
DataSet ds = new DataSet();
//Add the table to the DataSet
ds.Tables.Add(table);
//Write XML output to HDD where filename is full path
ds.WriteXml(filename);
I hope this helps give you a few hints.
|
|
|
|
|
hello,
i'm working on a .NET windows form. i have programmatically created a column of buttons using the following code:
for (int j = 0; j < farmData.Tables["plate"].Rows.Count; j++)
{
Button viewBtn = new Button();
viewBtn.Text = "View";
viewBtn.Name = "viewBtn" + j.ToString();
viewBtn.UseVisualStyleBackColor = true;
viewBtn.Click += new System.EventHandler(this.viewBtn_Click);
tbl.Controls.Add(viewBtn, 0, j + 2);
}
when i push a button, and the viewBtn_Click method is called, how do i get the button name so that i know exactly which button was pushed?
Thanks in adavance for any insight!
RC
|
|
|
|
|
You should be able to cast the sender parameter to Button type: Button button = (Button)sender;
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
that did the trick.
thank you!
|
|
|
|
|
could you direct me to any sites that explain how to use custom buttons on titlebar Close/Minimise etc
|
|
|
|
|
please read the top thread in here ("How to get your answers...")
posting the message twich is not very much smart like this.
the least you can do is search the codeproject for articles like this, but this is so small... just make a button, and register to the click event, and on the method you can do either
this.Minimise();<br />
this.Close();<br />
Application.Exit();
etc...
|
|
|
|
|
The title bar is a non-client area. You can't "just make a button" and drag it there as you would in the middle of a form. If it were that easy, the question likely would not have been posed.
Also, your making snide comments about how smart others' questions are is not recommended--at least not while this forum's contents can be searched through by name.
--
I've killed again, haven't I?
|
|
|
|
|
|
|
Why did you start a new thread when you already had one about this?
---
b { font-weight: normal; }
|
|
|
|
|
I have a component with COM Interop so its methods can be called from both .NET and COM applications.
I need to do the Windows Service that should do the same and which methods can be called from both .NET and COM. How could I convert this component to service?
Sorry for noob question, I am new with conceptions of Components and especially Services.
Thanks.
|
|
|
|
|
I am confused as to what your question is.
A Service is a process (.exe). You can use the component in the Service if that is what you mean.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
I've got a multi-tiered enterprise app, that I'm having trouble extending.
I want to build events into my DAL, but can't figure out how to do so without creating a circular reference.
I've got Architecture, DataAbstraction, and Data layers all in seperate DLLs. The architecture layer is simply a factory.
Wherever my events are handled I will need access to the DAL for data. Wherever the events live will need to trigger the handlers.
I can't think of a way to get this done without creating a circle in my references!
|
|
|
|
|
You can use an interface to declare the functionality required of your concrete object, code to the interface, and assign an concrete object to the interface member at runtime.
--
I've killed again, haven't I?
|
|
|
|
|
That's the route I've been down in trying to get this working, but I can't figure out how to lay it out. I still get a circle in every attempt I've made.
If "A" has events, and an interface that implements handlers in "B" and "B" needs to reference "A" to do it's job, how do I wire up the interface in "A"? I still need to reference A's dll from B, and vice versa, right?
|
|
|
|
|
When I ran into the circular reference issue, I found this page[^], which provided the info I needed. Part of the trick may be in determining which solves your particular situation better:
- A implements IA, and B has an IA member that gets assigned an A, or
- if B implements IB and A has an IB member that gets assigned a B
--
I've killed again, haven't I?
|
|
|
|
|
Im getting "The Server is not operational" when authenticating user to active directory
Any help plzz...
Thanks in advance
Krishna
|
|
|
|
|
Hello
I am new to the DLLImport, and I just cant figure out how it works.
I have seen in many other applications they use the DLLImport,
an example is:
[DllImport("KERNEL32.DLL", EntryPoint="MoveFileW", SetLastError=true,
CharSet=CharSet.Unicode, ExactSpelling=true,
CallingConvention=CallingConvention.StdCall)]
public static extern bool MoveFile(String src, String dst);
(found it in the MSDN libary)
Then my questen is how you know what to
write after the [DLLImport ("KERNEL32.DLL",
Is there a place to look it up? or are people just guessing what to write? :
Just to let you know, it is not the KERNEL32.DLL specific i want to know about, just about the dll's in general.
So if anyone know a place where to find this kind of information I would be happy.
Thanks
QzRz
|
|
|
|
|
|
You can go to pinvoke.net but why are you trying to call an unmanaged function (MoveFile) when you can just use File.Move() ?
|
|
|
|
|
It was just as an example, as it was the only thing I could find, but the pinvoke.net was exactly what I was looking after.
Thanks.
|
|
|
|
|
Is it possible to use custom buttons for close minimise
|
|
|
|
|