รบกวนดู Code ให้หน่อยค่ะว่าผิดยังไง
Run แล้วขึ้น Error ว่า [MySql][ODBC 5.1 Driver] Access Denied for user 'odbc'@'user' (using password : NO)
Private Sub Command1_Click()
Dim conDB As New ADODB.Connection
Dim HostIP, User, Pass, Port As String
Dim DBsource As String
Dim strCon As String
HostIP = "192.168.1.100"
DBsource = "MYDB"
Port = "3306"
User = "root"
Pass = ""
strCon = "Driver=Mysql ODBC 5.1 Driver; Server=" & HostIP & ";Port=" & Port & ";database = " & DBsource & ";dsq = myDSN" & _
";UID = " & User & ";PWD = " & Pass & ";option = 3 "
With conDB
If .State = adStateOpen Then .Close
.ConnectionString = strCon
.CommandTimeout = 90
.CursorLocation = adUseServer
.Open
If .State = 1 Then
Label1.Caption = "ติดต่อ MySQL ไ้ด้"
Else
Label1.Caption = "ติดต่อ MySQL ไม่ได้"
End If
End With
End Sub
หมายเหตุ
MySQL ติดตั้งอยู่บนเครื่อง Server ส่วน โปรแกรม Run ที่เครื่อง Client ค่ะ
เชื่อมต่อ VB 6.0 กับ MySQL ยังไง
Run แล้วขึ้น Error ว่า [MySql][ODBC 5.1 Driver] Access Denied for user 'odbc'@'user' (using password : NO)
Private Sub Command1_Click()
Dim conDB As New ADODB.Connection
Dim HostIP, User, Pass, Port As String
Dim DBsource As String
Dim strCon As String
HostIP = "192.168.1.100"
DBsource = "MYDB"
Port = "3306"
User = "root"
Pass = ""
strCon = "Driver=Mysql ODBC 5.1 Driver; Server=" & HostIP & ";Port=" & Port & ";database = " & DBsource & ";dsq = myDSN" & _
";UID = " & User & ";PWD = " & Pass & ";option = 3 "
With conDB
If .State = adStateOpen Then .Close
.ConnectionString = strCon
.CommandTimeout = 90
.CursorLocation = adUseServer
.Open
If .State = 1 Then
Label1.Caption = "ติดต่อ MySQL ไ้ด้"
Else
Label1.Caption = "ติดต่อ MySQL ไม่ได้"
End If
End With
End Sub
หมายเหตุ
MySQL ติดตั้งอยู่บนเครื่อง Server ส่วน โปรแกรม Run ที่เครื่อง Client ค่ะ