I just want to print the sql exception in my code. the statement is like this
Catch Msg As Data.SqlClient.SqlException
'On any Exception set the connection false
ConnectDb = False
writeLogdbconn(" in sql exception ") 'this method will print the message in text file at some directory location
Throw
I want to print the sql exception here. when I try this:
writeLogdbconn("in try - catch " & Msg)
gets the error
& operand is not defined for strings and sql exception.
Please suggest what should I used here for print the sql exception.
Msg
is a class, not a string. You probably need to use Msg.Message
.
writeLogdbconn("in try - catch " & Msg.Message)
You can also look at the example code on the MSDN page for Exception.Message.