gpt4 book ai didi

MySQL运行时错误 '-2147217865 (80040e37)'

转载 作者:行者123 更新时间:2023-11-29 11:10:33 25 4
gpt4 key购买 nike

Windows 7 (x64), VB6.0 - SP6 and MySQL 5.2 ODBC Connectors and Xammp Server

在本地主机上正常工作现在我尝试使用相同的表连接远程 MySQL 数据库,但成功连接后它给我运行时错误“-2147217865 (80040e37)”并显示表 mydatabase.tblusers 不存在,但实际上它存在于我的数据库中。我在互联网上搜索了所有可能的解决方案,但它仍然不适合我

这是我的连接字符串

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: " & err.Number & vbCrLf & "Description: " & 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

这是我的代码

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='" & txtUsername.Text & "' AND Password ='" & strPass & "' AND StatusCD ='ACTIVE'", CN, adOpenStatic, adLockReadOnly
If RS.RecordCount < 1 Then
Attempt = Attempt - 1
MsgBox "Username and/or Password is incorrect.Try Again!", vbExclamation
lblAttempt.Caption = "Remaining Attempt(s): " & 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='" & txtUsername.Text & "'", "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:" & Time

MDIMain.lblCurrentUser.Caption = ACTIVE_USER.FULLNAME
MDIMain.lblDate.Caption = Now() 'Format(Now, "MMMM dd, yyyy")

Unload Me
MDIMain.Show
End If
End Sub

最佳答案

远程服务器权限接受表名称(区分大小写),然后在代码中仔细检查远程服务器上的表名称。通过重命名所有相关表的 MySQL 语句解决了问题

关于MySQL运行时错误 '-2147217865 (80040e37)',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40659757/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com