Problem catching exception from a procedure

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

Guest

Hi!
I wrote a procedure in my sybase database this procedure is one line only,
and attemp to insert a record in a table generating a constraint violation of
a primary key and an exception.

I do this only for test...

then when I call the procedure from .net:

com.Connection = conn
com.CommandType = CommandType.StoredProcedure
com.CommandText = "PRUEBA"
Dim valor
Try
conn.Open()
com.ExecuteNonQuery()
Catch ex As System.Data.OleDb.OleDbException
ms = ex.Message
finally
conn.Close()
End Try

there is not excetion catch!!! , I try several code modification whitout
result...
 
I don't know anything about Sybase, but it's likely that the failure
to insert a record is not triggering an OleDbException. Code an
explicit return value or output parameter in your stored procedure
that tells your client code whether the insert succeeded or failed.
That's a more efficient way of handling it at the server ( thowing
exceptions is expensive on both ends).

--Mary
 
Back
Top