Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add this to module:
- ---------------------
- Private Mysql_Connection As New ADODB.Connection
- Private rs As New ADODB.Recordset
- Public Server As String
- Public Username As String
- Public Password As String
- Public Database As String
- Public Last_Query As String
- Public Array_Query As Variant
- Function Connect() As Boolean
- Connect = True
- On Error GoTo Err
- If Mysql_Connection.State = adStateOpen Then Mysql_Connection.Close
- Mysql_Connection.Open "driver={MySQL ODBC 3.51 Driver};server=" & Server & ";uid=" & Username & ";pwd=" & Password & ";database=" + Database
- Exit Function
- Err:
- Connect = False
- End Function
- Function Query(SQL As String) As Boolean
- On Error Resume Next
- With rs
- rs.Open SQL, Mysql_Connection
- MySQL.Last_Query = rs.GetString
- rs.Close
- End With
- End Function
- Function Fetch_Array(STR As String) As Boolean
- MySQL.Array_Query = Split(STR, vbTab)
- End Function
- Function CloseConnection()
- 'On Error Resume Next
- Mysql_Connection.Close
- End Function
- ------------------------------
- Usage:
- ------------------------------
- cmdHTLogin_Click()
- Dim player As Variant
- MySQL.Query ("select * from players where email=" & VBA.Chr(34) & email.Text & VBA.Chr(34) & " and pass=" & VBA.Chr(34) & pass.Text & VBA.Chr(34))
- MySQL.Fetch_Array (MySQL.Last_Query)
- player = MySQL.Array_Query
- Text1.Text = login(1)
- Private Sub Form_Load()
- MySQL.Server = "localhost"
- MySQL.Username = "root"
- MySQL.Password = "ur4dumb"
- MySQL.Database = "echocondria"
- MySQL.Connect
- End Sub
Add Comment
Please, Sign In to add comment