Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com
Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com

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 on Thursday, July 6, 2006 10:40 AM .Net Framework | Back to top


Comments on this post: Ado.Net 2.0 How SqlCommandBuilder works.

# re: Ado.Net 2.0 How SqlCommandBuilder works.
Requesting Gravatar...
You must provide the complete code to help the users, So that they can undersdand the complete logic.
Left by Ashutosh Kumar on May 22, 2009 5:47 PM

Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net