dcsimg
Results 1 to 2 of 2

Thread: Capturing Base SQL Error Through ADO Connection Object

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2014
    Posts
    60

    Capturing Base SQL Error Through ADO Connection Object

    Hi,

    Using VB6 and ADO 2.7 to connect to a SQL Server 2008 R2 system. Occasionally, we are presented with a SQL account lockout issue. Example code below:

    Code:
    Private Sub Connect()
        On Error GoTo err_Connect
        Dim oConn As New ADODB.Connection
        Dim sConn As String
        sConn = "Valid Connection String"
        oConn.Open sConn
    exit_Connect:
        Exit Sub
    err_Connect:
        MsgBox Err.Number & ": " & Err.Description
        Resume exit_Connect
    End Sub
    Using the above approach however masks the real error and instead presents it as a generic 'Invalid connection string attribute' error. How would I go about finding/presenting the base error from SQL?

    Any assistance is (as always) greatly appreciated!

    Best Regards
    Brad

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,426

    Re: Capturing Base SQL Error Through ADO Connection Object

    See Errors Collection (ADO).

    However... if the connection string is flawed you don't reach the Provider so there won't be any provider errors to see. I.e. it never even gets to SQL Server.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width