Class Library - How to show the error occur when using the method from the Class Library

  • Thread starter Thread starter Aron29
  • Start date Start date
A

Aron29

Guest
Good Day Everyone

I have created a Class Library, that has functionality that calls SQL procedures, then I import it on my ASP.NET MVC project, I'm okay when using my DLL but the problem is when the is an error happened inside the method, I have no idea what is the source or the cause of the error.

Public Sub queryExecute(sqlString As String, isStoredProcedure As Boolean, GetParameters() As String, GetParameterValues() As String)
Try

Dim connStr As String = ConfigurationManager.ConnectionStrings(connectionName).ToString

Using sqlConn As New SqlConnection(connStr)

Using sqlCmd As New SqlCommand(sqlString, sqlConn)

If isStoredProcedure = True Then
sqlCmd.CommandType = CommandType.StoredProcedure
Else
sqlCmd.CommandType = CommandType.Text
End If

Dim i As Integer, getI As Integer

getI = GetParameters.Length

For i = 0 To getI - 1
sqlCmd.Parameters.AddWithValue(GetParameters(i), GetParameterValues(i))
Next

sqlConn.Open()
sqlCmd.ExecuteNonQuery()
sqlCmd.Dispose()
sqlConn.Dispose()
sqlConn.Close()

End Using

End Using


Catch ex As Exception
MsgBox(ex.Message, vbOK, "Err")
Finally

End Try
End Sub

I tried to fix this by putting a Message box on the Exception, but the problem is the messagebox also shows on the website, when I'm debbugging my project, Is there a best way to handle this error and also know the message of the error?

thanks and regards.

Continue reading...
 
Back
Top