title: MySQL Run-time error '-2147217865 (80040e37)'
body: <blockquote>
    <p>Windows 7 (x64), VB6.0 - SP6 and MySQL 5.2 ODBC Connectors and Xammp
    Server</p>
  </blockquote>
  
  <p>that works properly on local host Now I am trying to connect with remote MySQL database with same tables but after successful connection it gives me Run-time error '-2147217865 (80040e37)' and says the table <strong>mydatabase.tblusers</strong> doesn't exist but actually its exist in my database.
  I searched over the internet for all possible solution but still its not working for me</p>
  
  <p><strong>Here is my connection string</strong></p>
  
  <pre><code>Option Explicit
  
  Public Function Connected2DB() As Boolean
  Dim isOpen      As Boolean
  Dim ANS         As VbMsgBoxResult
  Dim dbpath As String
  
      isOpen = False
      On Error GoTo err
  
      Do Until isOpen = True
        CN.CursorLocation = adUseClient
        CN.ConnectionString = "Provider=MSDASQL;Driver={MySQL ODBC 5.2 ANSI Driver};DSN=myDSN;Server=MyIPAddress;Database=myDatabase;Uid=DBUserName;Pwd=mypassword;Port=3306;"
        CN.Open
        isOpen = True
      Loop
      Connected2DB = isOpen
      Exit Function
  err:
      ANS = MsgBox("Error Number: " &amp; err.Number &amp; vbCrLf &amp; "Description: " &amp; err.Description, _
    vbCritical + vbRetryCancel)
    If ANS = vbCancel Then
      Connected2DB = False
    ElseIf ANS = vbRetry Then
      Connected2DB = vbRetry
    End If
  End Function
  
  Public Sub CloseDB()
      'Close the connection
      CN.Close
      Set CN = Nothing
  End Sub
  </code></pre>
  
  <p>and here is my code</p>
  
  <pre><code>Private Sub cmdLogin_Click()
  Dim strPass As String
  
  If txtUsername.Text = "" Then
      MsgBox "Username and/or Password is incorrect.Try Again!", vbExclamation
      txtUsername.SetFocus
      Exit Sub
  End If
  
  If txtPassword.Text = "" Then
      MsgBox "Username and/or Password is incorrect.Try Again!", vbExclamation
      txtPassword.SetFocus
      Exit Sub
  End If
  
  strPass = Encode(txtPassword.Text)
  'strPass = txtPassword.Text
  
  Set RS = New ADODB.Recordset
  'If RS.State = adStateOpen Then RS.Close
  RS.Open "SELECT tblUsers.* FROM tblUsers WHERE Username='" &amp; txtUsername.Text &amp; "' AND Password ='" &amp; strPass &amp; "' AND StatusCD ='ACTIVE'", CN, adOpenStatic, adLockReadOnly
  If RS.RecordCount &lt; 1 Then
      Attempt = Attempt - 1
      MsgBox "Username and/or Password is incorrect.Try Again!", vbExclamation
      lblAttempt.Caption = "Remaining Attempt(s): " &amp; Attempt
  
      If Attempt = 0 Then
          MsgBox "You have reached maximum login attempts. System will now be terminated!", vbExclamation
  
          MDIMain.CloseMe = True
          END_APP = True
          Unload Me
      End If
  Else
      LOGIN_SUCCEEDED = True
  
      ACTIVE_USER.USERID = RS.Fields("UserCD")
      ACTIVE_USER.FULLNAME = RS.Fields("Fullname")
      ACTIVE_USER.USERNAME = RS.Fields("Username")
      ACTIVE_USER.PASSCODE = RS.Fields("Password")
      ACTIVE_USER.USER_ISADMIN = CBool(changeYNValue(getValueAt("SELECT Username,IsAdmin FROM tblUsers WHERE Username='" &amp; txtUsername.Text &amp; "'", "IsAdmin")))
  
      blnCreate = CBool(changeYNValue(RS.Fields("ModCreate")))
      blnUpdate = CBool(changeYNValue(RS.Fields("ModUpdate")))
      blnDelete = CBool(changeYNValue(RS.Fields("ModDelete")))
  
      'InsertLogs Name, "Action Taken: Logged in to the Program", "Executed:" &amp; Time
  
      MDIMain.lblCurrentUser.Caption = ACTIVE_USER.FULLNAME
      MDIMain.lblDate.Caption = Now() 'Format(Now, "MMMM dd, yyyy")
  
      Unload Me
      MDIMain.Show
  End If
  End Sub
  </code></pre>