Hi,
What is use of commandbuilder class in .net. How will use sqlcommandbuilder class in my application. Plz, help me.
Thanks.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Suthish NairRank #92 · 22.8K reputationPosted Oct 10, 2011, 10:01 AM EDT
Prabhu RajaRank #861 · 2.6K reputationPosted Oct 10, 2011, 10:29 AM EDT
You can get more about CommandBuilder class in .NET by reading the following Article written by mahesh sir,
http://www.c-sharpcorner.com/UploadFile/mahesh/170/
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 10, 2011, 10:54 AM EDT
The SQLCommandBuilder generates single-table commands that are used to reconcile changes made to a DataSet with the associated SQL Server database.
Following is the simple example:
using (SqlConnection connection = new SqlConnection("connectionString"))
{
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = new SqlCommand("queryString", connection);
SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
connection.Open();
DataSet dataSet = new DataSet();
adapter.Fill(dataSet, tableName);
//code to modify data in DataSet here
builder.GetUpdateCommand();
//Without the SqlCommandBuilder this line would fail
adapter.Update(dataSet, tableName);
return dataSet;
}
Please do not forget to mark "Accepted Solution"
Suthish NairRank #92 · 22.8K reputationPosted Oct 10, 2011, 10:59 AM EDT