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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Suthish NairPosted Oct 10, 2011, 2:59 PM
Javeed M ShaikhPosted Oct 10, 2011, 2:54 PM
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"
Prabhu RajaPosted Oct 10, 2011, 2:29 PM
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/
Suthish NairPosted Oct 10, 2011, 2:01 PM