Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Errors not being sent back to client

Status
Not open for further replies.

ralphtrent

Programmer
Joined
Jun 2, 2003
Messages
958
Location
US
Hi have a C# client server app. The client is inputting customer information. I have Stored Procs (SP) on my MSSQL server that is updating and inserting the data. When I go to add a record. I call another SP that checks to see if some data exists, if it does, I do a RASIERROR SQL Function if the data does not exists i do nothing. When I run the test via the client and cause duplicate data, nothing happens the data gets updated. When i run the duplicate testing sp via an sql client, i get the error that I raised. How come this error does not makes its way back to the client? I do have try{} catch{} blocks in my c#

Thanks.
 
I'm just throwing this out. I think that you need to look for that error message.

Here is a simple example. In the SP set the (@RETURN_VALUE to the error code.

Hope this helps. Again this is a stab in the dark.

Dim conn As System.Data.SqlClient.SqlConnection
Dim strCommandText As String = "sfsp_SpecialOfferItemsGet"
Dim intSPReturn As Integer
Dim params(2) As SqlParameter

params(0) = New SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4)
params(0).Direction = ParameterDirection.ReturnValue

params(1) = New SqlParameter("@strZipCode", SqlDbType.NVarChar, 5)
params(1).Value = strZipCode

params(2) = New SqlParameter("@intCarrierID", SqlDbType.Int, 4)
params(2).Value = intCarrierID

GetConnection(conn, "PRODUCT_CONNECTION_STRING")
dsSpecialOfferItems = ExecuteDataSet(conn, CommandType.StoredProcedure, strCommandText, params)
If conn.State = ConnectionState.Open Then
conn.Close()
End If
conn.Dispose()
intSPReturn = params(0).Value

If intSPReturn = 0 Then
Return True
Else
Return False
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top