Windows Develop Bookmark and Share   
 index > Windows Forms General > how to use command builder class
 

how to use command builder class

i have a form on which i takes values from user..like name, id , address and contact no, and want to store these information in table in database.

and as user enters the information, he/she can insert/update/delete in the table.

i want to perform these operations using command builder ...

please help me.

Vishie  Wednesday, May 27, 2009 3:45 PM
Here is an article that introduces command builder. It might be a good place to start:

http://www.programmersheaven.com/2/FAQ-ADONET-CommandBuilder-Prepare-Dataset
www.insteptech.com
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
DeborahK  Wednesday, May 27, 2009 3:49 PM
Well you need to read up on it to discover that.

Generating Commands with CommandBuilders (ADO.NET)

John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com
JohnGrove  Wednesday, May 27, 2009 4:05 PM
Hi Vishie,

You can call the EndCurrentEdit method on the CurrencyManager associated with the data source to apply pending changes to the data source and then call the Update method on the DataAdapter to save changes back to database. The following is a sample:

SqlDataAdapter da = new SqlDataAdapter("select * from tablename","connection string");
SqlCommandBuilder cb = new SqlCommandBuilder(da);
da.Fill(dataset, "tablename");
// make some changes in the data source
// ...
this.BindingContext[dataset, "tablename"].EndCurrentEdit();
da.Update(dataset,"tablename");
dataset.AcceptChanges();

Hope this helps.

Sincerely,
Linda Liu
Please remember to mark the replies as answers if they help and unmark them if they provide no help. end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
Linda Liu  Wednesday, June 03, 2009 9:35 AM
Here is an article that introduces command builder. It might be a good place to start:

http://www.programmersheaven.com/2/FAQ-ADONET-CommandBuilder-Prepare-Dataset
www.insteptech.com
We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
DeborahK  Wednesday, May 27, 2009 3:49 PM
I would also read this article:

Weaning Developers from the CommandBuilder
John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com
JohnGrove  Wednesday, May 27, 2009 3:52 PM
but how the get insert or other command wil take the data from the form..and insert into the table??
Vishie  Wednesday, May 27, 2009 3:55 PM
Well you need to read up on it to discover that.

Generating Commands with CommandBuilders (ADO.NET)

John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com
JohnGrove  Wednesday, May 27, 2009 4:05 PM
Hi Vishie,

You can call the EndCurrentEdit method on the CurrencyManager associated with the data source to apply pending changes to the data source and then call the Update method on the DataAdapter to save changes back to database. The following is a sample:

SqlDataAdapter da = new SqlDataAdapter("select * from tablename","connection string");
SqlCommandBuilder cb = new SqlCommandBuilder(da);
da.Fill(dataset, "tablename");
// make some changes in the data source
// ...
this.BindingContext[dataset, "tablename"].EndCurrentEdit();
da.Update(dataset,"tablename");
dataset.AcceptChanges();

Hope this helps.

Sincerely,
Linda Liu
Please remember to mark the replies as answers if they help and unmark them if they provide no help. end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
Linda Liu  Wednesday, June 03, 2009 9:35 AM

You can use google to search for other answers

Custom Search

More Threads

• launch winform apps from winform apps.
• Lazy True Transparent Label
• forms seperator line
• calling the 'on_load' event or re-setting the form ?
• print string by multiple printers
• Communicate from webbrowser control to windows forms
• Adding a custom icon to a form, next to minimize, maximize and close in top right
• Application on Close event in Visual Studio 2005
• MID questin
• GUI Design Issue