Re: SqlDataAdapter Questions

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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" <hartley_aaron@xxxxxxxxxxx> wrote in message
news:1154375655.450193.271690@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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



.



Relevant Pages

  • Re: Convert DataSet To Excel
    ... DeleteCommand and UpdateCommand to the commands that will ... feed the dataset to the Update method on ... the DataAdapter, and it should work. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: What is the purpose of AcceptChanges?
    ... dataset where you do the deleted first up the parent chain, ... when using the Update method in typical fashion it's not required. ... For example, I can pull ten rows from a datasource into a dataset, ... are no changes available in the dataset for the adapter to send back. ...
    (microsoft.public.dotnet.framework.adonet)
  • [long] Oubtfuls questions on test199 (from Redbook)???
    ... A system administrator has just moved an Ethernet adapter to another ... The netstat and ifconfig commands show the interface just as ... The adapter speed has changed to 10 Mbps. ... Kbytes allocated to mbufs ...
    (comp.unix.aix)
  • RE: Latest Adaptec AACRAID driver doesnt compile on latest kernel
    ... >> We never look at it except for the old megaraid driver that abuses it ... >> for sending internal commands. ... On Tue, 2 Aug 2005, Salyzyn, Mark wrote: ... > quiesced to the adapter. ...
    (Linux-Kernel)
  • Re: Updated dataset back to the database
    ... "So even if the adapter is disposed and you can't change that - ... Ryan, Would you provide a sample code for this scenario? ... > process is done for each of the other types of commands - insert and update. ... > configured correctly or not disposing of the first one and using it again - ...
    (microsoft.public.dotnet.general)