Am I opening and closing my ODBC connection incorrectly?
When connecting to a Sybase ASE database via ODBC using the code below, I'll occasionally get a '[IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed' error.
Can this be caused by my code? I read here that I should be using the 'With' statement instead, but I don't understand how that would affect this.
Thanks in advance!
Try
odsConn.Open()
Dim acctCheckString As String = sB.ToString
Dim odsCmd As New OdbcCommand(acctCheckString, odsConn)
odsRtrn = CStr(odsCmd.ExecuteScalar).TrimEnd
开发者_如何学编程 Catch ex As Exception
odsRtrn = ex.Message.ToUpper
odsRtrn = CheckError(odsRtrn)
Finally
odsConn.Close()
End Try
I apologize for interjecting without an answer to your specific question, but if I might make a suggestion...
In the year 2009, if you are using vb.Net, and you are still using ODBC, you should please (seriously) check out ADO.Net managed code data providers. There is one for Sybase...
SyBase ADO.Net Providers
This will completely replace the odbc libraries. they are much easier to use.
精彩评论