Guest User

Untitled

a guest
Jun 18th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. Add this to module:
  2. ---------------------
  3. Private Mysql_Connection As New ADODB.Connection
  4. Private rs As New ADODB.Recordset
  5.  
  6. Public Server As String
  7. Public Username As String
  8. Public Password As String
  9. Public Database As String
  10. Public Last_Query As String
  11. Public Array_Query As Variant
  12.  
  13.  
  14. Function Connect() As Boolean
  15. Connect = True
  16.  
  17. On Error GoTo Err
  18.  
  19. If Mysql_Connection.State = adStateOpen Then Mysql_Connection.Close
  20.  
  21. Mysql_Connection.Open "driver={MySQL ODBC 3.51 Driver};server=" & Server & ";uid=" & Username & ";pwd=" & Password & ";database=" + Database
  22.  
  23. Exit Function
  24.  
  25. Err:
  26. Connect = False
  27. End Function
  28.  
  29.  
  30. Function Query(SQL As String) As Boolean
  31. On Error Resume Next
  32. With rs
  33. rs.Open SQL, Mysql_Connection
  34. MySQL.Last_Query = rs.GetString
  35. rs.Close
  36. End With
  37. End Function
  38.  
  39. Function Fetch_Array(STR As String) As Boolean
  40. MySQL.Array_Query = Split(STR, vbTab)
  41. End Function
  42.  
  43.  
  44. Function CloseConnection()
  45. 'On Error Resume Next
  46. Mysql_Connection.Close
  47. End Function
  48.  
  49.  
  50. ------------------------------
  51.  
  52. Usage:
  53.  
  54. ------------------------------
  55.  
  56. cmdHTLogin_Click()
  57. Dim player As Variant
  58.  
  59. 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))
  60. MySQL.Fetch_Array (MySQL.Last_Query)
  61. player = MySQL.Array_Query
  62. Text1.Text = login(1)
  63.  
  64. Private Sub Form_Load()
  65. MySQL.Server = "localhost"
  66. MySQL.Username = "root"
  67. MySQL.Password = "ur4dumb"
  68. MySQL.Database = "echocondria"
  69. MySQL.Connect
  70. End Sub
Add Comment
Please, Sign In to add comment