Problem catching exception from a procedure

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...
 
M

Mary Chipman

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top