Hi Stephen,
You're not going to be able to step through the Stored Procedure via your
application debugging, as it is not part of your compiled code. However, you
are, of course, calling the Stored Procedure, and (I would imagine) passing
parameters to it. You have also already established that the Stored
Procedure is not at fault. So, you could certainly step through the code
that prepares the SqlCommand, and see what your code is doing wrong that is
causing the SQL Server to raise an exception. You can use Watches and
QuickWatches to view the values of the various objects being worked with at
any time. In addition, the SqlException class has a number or helpful
members that expose more information about the exception than the Message
alone. Here is a VB.Net Function I wrote that returns most of this
information in a formatted string:
Public Shared Function GetSqlException(ByVal ex As SqlException) As
String
Try
Dim sb As StringBuilder = New StringBuilder("SqlException:" &
vbCrLf & "Errors:" & vbCrLf)
For i As Integer = 0 To ex.Errors.Count - 1
sb.Append(ex.Errors(i).Server & ": " &
ex.Errors(i).Procedure & ": Error Number" & _
ex.Errors(i).Number.ToString())
sb.Append("Line Number " &
ex.Errors(i).LineNumber.ToString() & vbCrLf)
sb.Append(ex.Errors(i).Message)
If Not IsNothing(ex.InnerException) Then
sb.Append("Inner Exception: " &
ex.InnerException.GetType().ToString() & vbCrLf)
sb.Append(ex.InnerException.Message)
End If
Next
Return sb.ToString()
Catch e As Exception
Utilities.HandleError(e)
Return "Error getting SqlException: " & e.Message
End Try
End Function
Of course you would have to implement your own exception handling for it. I
use my own Handler that writes to the Event Log. How you want to do it is up
to you.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
"Stephen Noronha" <st********@hotmail.com> wrote in message
news:uC**************@TK2MSFTNGP14.phx.gbl...
Hi,
I get an error "System.Data.SqlClient.SqlException", after my Stored
Procedure runs and i saw an article for debugging through the Stored
procedure using VS .Net.
http://techrepublic.com.com/5100-10878_11-5161626.html
i dont use the wizard and create and write data access components myself.
The Stored Procedure runs fine in Query Analyser, but I am goofing
somewhere
in the code,
so is there a way i can step through the stored procedures and see whether
I
am passing values correctly?
I have no idea whether this is the right group to post my question, but I
have anyway. if you feel that I should post it somewhere, please do point
me
to an appropriate group to post.
Thanks,
Stephen