SP fails, but OleDbCommand does not throw error!

  • Thread starter Thread starter John Mark Howell
  • Start date Start date
J

John Mark Howell

BlankI have found a major problem with the OleDb portion of ADO.NET. If you
are using it to call a stored procedure and the procedure has an internal
error of some type, the sp will fail, but the OleDbCommand object will not
throw any type of error.
For example, I have a proc that does an insert and I pass in a value for one
of the parameters that will cause a foreign key violation. The call the
proc will complete but nothing will be inserted. I can create that same
insert statement and call it with an OleDbCommand object and will get the
error.
Other than a return value, does anyone know how to get a call to an SP to
throw an error when it fails??????
 
We need more information than that in order to provide assistance. Mainly,
what database are you using, and what ODBC provider? I doubt it's a problem
with ADO.NET, only because that's something important enough to have been
caught and fixed by now, I'm sure. Also note that it's up to the ODBC
provider to send notification of an error. Make sure you're using the latest
version.

I don't normally use ODBC Providers, so this may be by design and someone
may have a better answer for you, however it would be very helpful if you
could provide more information regarding your specific problem. What
database are you using? What is the code you are using to execute your
command? What version ODBC provider?

--ROBERT
 
Correction: OleDB Providers. :) It's one of those mornings.

--ROBERT

Robert Bouillon said:
We need more information than that in order to provide assistance. Mainly,
what database are you using, and what ODBC provider? I doubt it's a problem
with ADO.NET, only because that's something important enough to have been
caught and fixed by now, I'm sure. Also note that it's up to the ODBC
provider to send notification of an error. Make sure you're using the latest
version.

I don't normally use ODBC Providers, so this may be by design and someone
may have a better answer for you, however it would be very helpful if you
could provide more information regarding your specific problem. What
database are you using? What is the code you are using to execute your
command? What version ODBC provider?

--ROBERT
 
BlankI have found a major problem with the OleDb portion of ADO.NET. If you
are using it to call a stored procedure and the procedure has an internal
error of some type, the sp will fail, but the OleDbCommand object will not
throw any type of error.
For example, I have a proc that does an insert and I pass in a value for one
of the parameters that will cause a foreign key violation. The call the
proc will complete but nothing will be inserted. I can create that same
insert statement and call it with an OleDbCommand object and will get the
error.
Other than a return value, does anyone know how to get a call to an SP to
throw an error when it fails??????

I have also had this problem when using the ExecuteNonQuery() method.
My work-around was to check if the resultant number of rows affected
was 0. Then I would throw a custom error or take some other action.
E. Bender
 
Back
Top