how to check for action when tableadapter.udpate

adshocker

Well-known member
Joined
Jun 30, 2007
Messages
180
Programming Experience
Beginner
hi all,

i need to track down if the tableadapter.update command will do an insert, update, or delete on my datatable.

i used typed datasets on my application. my bindingnavigator, bindingsource where all generated automatically when i dragged a table from my data sources window to my form. then when i double-clicked my save button on the bindingnavigator it pointed me to the savebutton.click event where there's the autogenerated validate, endedit and update commands.

now, my application will calling 3 different procedures depending on what action the tableadapter.update will do. for example, if there's an insert, i will add on the savebutton.click and call proc_when_insert if there's an update, i will add proc_when_update procedure and so on.

how do i do this?

thanks.
 
Last edited by a moderator:
the update command automatically calls the correct procedure as it's all coded in the background...

if it detects a row has been deleted in the dataTable, it will called .delete

if it detects a row has been added in the dataTable, it will call .insert

if it detects a row has been modified in the dataTable, it will call .update

If you are planning on using 3 Stored Procedures instead, you will have to alter the code and have some kind of validation check so that the sub knows what of the 3 commands it is doing.

I may be wrong, and get corrected, but that's as far as I understand how it works.
 
thanks...

after several research on how to determine if the update will call .delete, i came up with this.
VB.NET:
Dim tmpDataTable As DataTable = Me.MainDataSet.USERS_PROFILE.GetChanges(DataRowState.Deleted)
Dim tmpRow As DataRow
 For Each tmpRow In tmpDataTable.Rows
  MessageBox.Show(tmpRow(0, DataRowVersion.Original).ToString
 Next
 
Back
Top