471,330 Members | 1,406 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

About SqlCommandBuilder


This small program below works but I have some questions about it.

Below I have a piece of code that update a specific row in the northwind
The class SqlCommandBuilder is used for creating a suitable update,insert or
delete sql command that
match thisAdapter.

If I look at the object thisBuilder in the debugger on for example
UpdateCommand this is null
but the class SqlCommandBuilder should create a suitable update command.

So my first question is why the UpdateCommand for thisBuilder is null ?
My second question is if it's possible to see the update command that
thisBuilder is creating ?

static void Main(string[] args)
//Specify SQL Server-specific connection string
SqlConnection thisConnection = new SqlConnection(
@"Server=UHT-DEMO1;Integrated Security=True;" +

//Create DataAdapter object for update and other operations
SqlDataAdapter thisAdapter = new SqlDataAdapter(
"Select CustomerID, CompanyName from Customers",

//Create CommandBuilder object to build SQl commands
SqlCommandBuilder thisBuilder = new

//Create DataSet to contain related data tables, rows and
DataSet thisDataSet = new DataSet();

//Fill DataSet using query defined previously for DataAdapter
thisAdapter.Fill(thisDataSet, "Customers");

//Show data before change is made
Console.WriteLine("Name before change: {0}",

//Change data in Customers table, row 9, CompanyName column
thisDataSet.Tables["Customers"].Rows[9]["CompanyName"] = "Acme,

//Call Update command to mark change in table
thisAdapter.Update(thisDataSet, "Customers");

Console.WriteLine("Name after change: {0}",


Console.WriteLine("Program finished, Press Enter/Return to
Aug 20 '08 #1
0 1068

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by microsoft.private.windows.netserver.setup | last post: by
4 posts views Thread by Jim Reynolds | last post: by
9 posts views Thread by cherishman | last post: by
reply views Thread by DG | last post: by
1 post views Thread by Tony Johansson | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.