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.

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:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345