Ado.Net 2.0 How SqlCommandBuilder works.

I've debugged my code that uses SqlCommandBuilder:

 

Dim daJoinTable As New SqlDataAdapter(sSQLSelect,connString)
Dim
cbJoinTable As New SqlCommandBuilder(daJoinTable)
daJoinTable.Update(dsJoinTable.Tables(0))

and noticed that daJoinTable.UpdateCommand,InsertCommand and DeleteCommand are nulls, when I expected that they will be generated by SqlCommandBuilder.
Even if code works fine, I was curious, how dataadapter knows which 
 update SQL command should be used. I found a good article about SqlCommandBuilder, but it doesn't go into this level of details.

With help of Reflector, I understood that  SqlCommandBuilder constructor calls SetRowUpdatingHandler(DbDataAdapter adapter), to use protected DbCommandBuilder.RowUpdatingHandler when row is about to be updated.
The implementation of  RowUpdatingHandler replaces null commands with commands generated by DbCommandBuilder for each updated row.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted @ Thursday, July 06, 2006 10:40 AM
Print

Comments on this entry:

# re: Ado.Net 2.0 How SqlCommandBuilder works.

Left by Ashutosh Kumar at 5/22/2009 5:47 PM
Gravatar
You must provide the complete code to help the users, So that they can undersdand the complete logic.

Your comment:



(not displayed)


 
 
 
 
 

Live Comment Preview:

 
«February»
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910