SQLException: retrieve the SQL command string associated with a syntax error?

  • Thread starter Thread starter K. Shier
  • Start date Start date
K

K. Shier

VB.Net

i catch an SQLException having message: "Line 1: Incorrect syntax near
'ContractNum'." while trying to update a datasource via a data adapter.

is there any way to retrieve the SQL command string that caused the error
directly from the Exception object? I can, of course, get the strings out
of the DataAdapter's command objects, but i don't want those - i want to see
exactly what is being sent to SQL Server.

i have looked around the object hierarchy of SQLException and SQLError but i
don't see anything that looks like what i need.

any insight would be much appreciated! THANKS!
 
You can't get the command from the Exception. If you use
Microsoft SQL Server you can use the run the SQL Profiler
against your data base, the profiler will show you all the
call made to you SQL server. This could help you to see
the query that went wrong.

/Fredrik Normén NSQUARED2
http://www.nsquared2.net
 
Back
Top