By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,633 Members | 1,905 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,633 IT Pros & Developers. It's quick & easy.

SqlDataAdapter Questions

P: n/a
Hello,

The SqlDataAdapter has 4 properties of type SqlCommand, SelectCommand,
UpdateCommand, DeleteCommand, and InsertCommand. Setting the
SelectCommand allows the SqlDataAdapter to retrieve data from the
database using the fill method. Aside from that, I don't see much of a
difference. The SelectCommand can be used to insert, update, and
delete all by using the ExecuteNonQuery method. So UpdateCommand,
DeleteCommand, and InsertCommand seem to be somewhat redundant.

The SqlDataAdapter Update method is supposed to, relative to the data
obtained from the Fill method, writeback any changes to the database.
The documentation for UpdateCommand, etc is vague but seems to indicate
that the developer can use UpdateCommand, etc to override or supplement
the auto generated commands when Update is executed (????).

What is the function of these commands?

Thanks,
Aaron

Jul 31 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
No 'default' commands are generated by the adapter. The developer is
supposed to set UpdateCommand, InsertCommand, DeleteCommand so that during
Update, the adapter can use these commands to send the corresponding row
changes to the database.

If you don't use the Update method, then yes, there is no point in defining
these.

If you do use the Update method of the adapter, then unless you set these,
you will get an exception when the adapter tries to use them.

If you use the SqlCommandBuilder, then you do not need to set these
properties, as the SqlCommandBuilder provides the commands on demand to the
adapter.

"Aaron" <ha***********@hotmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hello,

The SqlDataAdapter has 4 properties of type SqlCommand, SelectCommand,
UpdateCommand, DeleteCommand, and InsertCommand. Setting the
SelectCommand allows the SqlDataAdapter to retrieve data from the
database using the fill method. Aside from that, I don't see much of a
difference. The SelectCommand can be used to insert, update, and
delete all by using the ExecuteNonQuery method. So UpdateCommand,
DeleteCommand, and InsertCommand seem to be somewhat redundant.

The SqlDataAdapter Update method is supposed to, relative to the data
obtained from the Fill method, writeback any changes to the database.
The documentation for UpdateCommand, etc is vague but seems to indicate
that the developer can use UpdateCommand, etc to override or supplement
the auto generated commands when Update is executed (????).

What is the function of these commands?

Thanks,
Aaron

Jul 31 '06 #2

P: n/a
Hello Aaron,
The DUI commands are to do exactly what they say they do.... Insert... Delete
and Update. They are used by the Adaptor to perform those actions when the
Update method is called. Typically you use the CommandBuilder to build the
proper commands to insert into the DUI Commands. OR, like you said to override
the default values.... IE, if only some of the fields are to be updated.

In a nutshell, they are the commands that the adaptor will use when saving
(or deleting) the data to the database.
-Chris Anderson [MVP-VB]
Hello,

The SqlDataAdapter has 4 properties of type SqlCommand, SelectCommand,
UpdateCommand, DeleteCommand, and InsertCommand. Setting the
SelectCommand allows the SqlDataAdapter to retrieve data from the
database using the fill method. Aside from that, I don't see much of
a difference. The SelectCommand can be used to insert, update, and
delete all by using the ExecuteNonQuery method. So UpdateCommand,
DeleteCommand, and InsertCommand seem to be somewhat redundant.

The SqlDataAdapter Update method is supposed to, relative to the data
obtained from the Fill method, writeback any changes to the database.
The documentation for UpdateCommand, etc is vague but seems to
indicate that the developer can use UpdateCommand, etc to override or
supplement the auto generated commands when Update is executed (????).

What is the function of these commands?

Thanks,
Aaron

Jul 31 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.