문제

I connect my windows mobile app directly to ms-sql server using the sqlclient dll from microsoft. Some times I get this error when trying to get some data from the server:

System.Data.SqlClient.SqlException: SqlException
at System.Data.SqlClient.SqlConnection.OnError()
at System.Data.SqlClient.SqlInternalConnection.OnError()
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Run()
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.ExecuteReader()
at System.Data.SqlClient.SqlCommand.ExecuteReader()

Every time I have a error like this I need to try a few other things, some times the connection string is no good, or the network is not configured right or any other random problem.

Is there a way I could get a bit more info from the program so I shouldn't have to waste a few hours figuring out what might went rung?

도움이 되었습니까?

해결책 2

Ok I found the answer... I changed: Catch ex As Exception To: Catch ex As SqlException

Now I get the specific error nicely displayed in the message.

다른 팁

That's basically just the stack trace. You should be able to get the Message property of the SqlException which contains the details. In some cases you will have to look at the InnerException to get to the interesting details.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top