-
'Here I create a variable named MySQL as a new connection object for MySQL
-
Global MySQL As New MySQL_CONNECTION
-
-
Private Function MySQL_Connect() As Boolean
-
Dim res_MySQL As MYSQL_CONNECTION_STATE
-
-
MySQL_Connect = False
-
res_MySQL = MySQL.OpenConnection("server", "username", "password", "database", 3306, CLIENT_COMPRESS)
-
-
If res_MySQL = MY_CONN_OPEN Then
-
MySQL_Connect = True
-
End Function
-
-
' Query -> MySQL query to execute.
-
' CloseRS -> Optional. Close recordset created after executing Query.
-
' RS -> Optional. Reference to externaly created variable, declared as MYSQL_RS. If not closed, it will be available to the program after the query is executed.
-
' lAffected -> Optional. Numer of rows affected after te Query.
-
Public Sub SQLQuery(ByVal Query As String, Optional ByVal CloseRS As Boolean = False, Optional ByRef RS As MYSQL_RS, Optional ByRef lAffected As Long)
-
Dim ERR As MYSQL_ERR
-
-
Set RS = MySQL.Execute(Query, lAffected)
-
Set ERR = MySQL.Error
-
-
If ERR.Number <> 0 Then
-
' Handle any eventual errors that occurred during MySQL query
-
End If
-
ERR.Clear
-
Set ERR = Nothing
-
-
If CloseRS Then
-
RS.CloseRecordset
-
Set RS = Nothing
-
End If
-
End Sub
- Continue reading...