How to capture sql command text when DbDataAdapter's Update is cal

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

We are having a major debugging problem here and would like to take advices
from anyone.

In our app, we need to update our dataset using DbDataAdapter against Oracle
database. Once we have issues, like invalid data or something like that, the
update will fail but only with limited returned message. It would be extramly
helpful if we could somehow capture the SQL text that built by the ADO.Net,
right before or after the Update is called. Is there a way to do that?

Thanks

Feng
 
Feng,

Yes there is a way. Right at the RowUpdating event of the datatable being
updated, check the

DbDataAdapter.InsertCommand.CommandText
DbDataAdapter.UpdateCommand.CommandText
DbDataAdapter.DeleteCommand.CommandText
 
Thanks Sahil for your response. For some reason, I couldn't find the
"RowUpdating" event of a datatable class. Do you mean RowChanging? But that's
not what need. It's too early in timing. I want to capture the SQL string
RIGHT BEFORE it is sent to the database.

Any idea?

Thanks again!

Feng
 
Back
Top