473,382 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 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 1133

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Nick | last post by:
Hi, The SqlCommandBuilder class seems to be able to remember the primary key of a row such that even if I change that key's value, it is still able to update only that row. So I would like to...
by: EMW | last post by:
I've posted serveral times to get an answer, but till now still now satisfying answers. Here is my problem: I have filled a datagrid control with the contents of an Excel sheet. Over 3500...
by: Hank1234 | last post by:
Can I use one Data Adapter and one Command Builder to update amny tables? Currently in my data adapter I query two tables and fill them into two tables in a data set. When I make a change to a...
by: microsoft.private.windows.netserver.setup | last post by:
I have a very strange thing occurring in the program. I have a dataset retrieved from a stored procedure that just select * from a table. I then try to use the SQlCommandBuilder on the dataset,...
by: Jim Reynolds | last post by:
Hi, I am using a SqlCommandBuilder to update a Db table via an updated DataSet and SqlAdapter and it doesn't seem to be generating the activity commands from the Select command. Here is a snippet....
by: cherishman | last post by:
When I use self-defined database, sometimes the dataadapter can't auto create insertcommand, updatecommand and deletecommand, it just only create selectcommand? But when I use these database such...
by: DG | last post by:
I use this code: _adapter = new SqlDataAdapter(selectString, _conn); _adapter.SelectCommand = new SqlCommand(selectString, _conn); _adapter.SelectCommand.Transaction = _trans; _builder = new...
by: Tony Johansson | last post by:
Hello! When I use this SqlCommandBuilder will there be created sql command for all three sql statement(update,insert and delete) //Tony
by: raulbolanos | last post by:
Hi Pr0's, I have a problem trying to implement the same example from this link: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommandbuilder.aspx But instead of Sql I use...
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.