|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
SqlDataAdapter QuestionsThe 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 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. Show quoteHide quote "Aaron" <hartley_aa***@hotmail.com> wrote in message news:1154375655.450193.271690@m73g2000cwd.googlegroups.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 > 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] Show quoteHide quote > 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 |
|||||||||||||||||||||||