why and when to use sqlCommandBuilder

  • Thread starter Thread starter naruto2000x
  • Start date Start date
N

naruto2000x

Hi


Before that, Sahil thanks for your help before.

Here is my other question. (sorry, i am new to ADO.net, so i have a
lot of question)

i know that sqlCommandBuilder is used to generate the insert, update
and delete command of the DataAdapter.

However why is it neccesary to use the the sqlcommandbuilder (together
with the Update method of the data adapter to write the changes back
to the database)?

What i mean is that when we pass a sql UPDATE, INSERT, or DELETE
statement to the data adapter contructor follows by its fill method,
the database will automatially get updated based upon the sql
statement that we pass in. So in what situation we will use thid sql
command builder together with update method?


thanks

winnie

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
Winnie,

You should try and avoid using SqlCommandBuilder as a matter of fact.

Why?

1. It generates inefficient statements.
2. It cannot generate sql for every single possible case.

However you could use commandbuilder at ---
a) Design time.
b) Non production app
c) Quick and dirty non - performance oriented app where the priority is
writing lesser code and getting it done.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 
Thanks, Sahil

Since there are options to use between SQLCommand object(with various
execute method such as executereader) and Data Adapter (together with
data set) when we interact with the underlying database, which method
would you recommend?

Both object can be used to INSERT, UPDATE and DELETE data in the
database (of course, together with sql statement).
i just don't know which one to use, and in what situation we use
them?


thanks

winnie

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
Back
Top