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 itf code works fine, I was curious, how dataadapter knows which 
 update SQL command should be used. I gound a good article about SqlCommandBuilder, but it desn'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:

No comments posted yet.

Your comment:



 (will not be displayed)


 
 
 
Please add 3 and 6 and type the answer here:
 

Live Comment Preview:

 
«December»
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910