Well, I have something like this:
Dim DateStamp As String
Dim TimeStamp As String
Dim VerifyUsername As String
Dim VerifyPassword As String
Dim RecordsCounted As Long
MySQL_User = "××××" ' user name to MySQL (normally root or admin)
MySQL_Password = "××××" ' password to MySQL
MySQL_Server = "localhost" ' localhost is normally used <---- this is the problem
MySQL_Database = "×××" ' name of your database
Dim QueryString As String
user = txtun.Text
pass = txtpw.Text
QueryString = "Select * From users WHERE username='" & user & "' AND password='" & pass & "';"
QueryDatabase QueryString 'Run the query
RecordsCounted = RecordCount() 'Counts the records returned
' ALL RECORDS START AT 1, NOT ZERO. :P
VerifyUsername = getCell("username", 1) ' Returns row 1, column username
VerifyPassword = getCell("password", 1) ' Returns row 1, column password
-------------------------------------------------------------------------------------
' THE CONNECTION IS IN THE MYSQL.BAS FILE :
Public Sub ConnectMySQL()
Dim ErrorDescription As String
Dim ErrorNumber As String
Dim Verifycount As Long
Dim VerifyStamp As String
On Error GoTo PerformErr
isMySQLConnected = False
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.CursorLocation = adUseClient
conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _
& "SERVER=" & MySQL_Server & ";" _
& "DATABASE=" & MySQL_Database & ";" _
& "UID=" & MySQL_User & ";" _
& "PWD=" & MySQL_Password & ";" _
& "OPTION=" & 1 + 2 + 8 + 32 + 2048 + 16384
conn.Open
isMySQLConnected = True
Verifycount = 0
' Verify Connection Once
Exit Sub
PerformErr:
' Failed to connect
ErrorDescription = Err.Description
ErrorNumber = Err.Number
MsgBox "A MySQL Connection Error has been returned: " & ErrorDescription & "[" & ErrorNumber & "]", vbCritical, "Could not connect to MySQL"
PerformErr_NoStandardError:
isMySQLConnected = False
End Sub
I hope you understand this basic code, but I dont want to connect to localhost but to: 84.29.112.123
No one has replied yet! Why not be the first?
Sign in or Join us (it's free).