1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
Function Connection()
Dim source As String, location As String, user As String, password As String, mysql_driver As String, database As String
source = "MySQL"
location = "localhost"
user = "root"
password = ""
database = "monsite"
mysql_driver = "MySQL ODBC 5.2 ANSI Driver"
'Build the connection string
Dim connectionString As String
connectionString = "Driver={" & mysql_driver & "};Server=" & location & ";Database=" & database & ";UID=" & user & ";PWD=" & password & ""
'Create and open a new connection to the selected source
Set OpenConnection = New ADODB.Connection
OpenConnection.CursorLocation = adUseClient
Call OpenConnection.Open(connectionString)
End Function
Sub Macro1()
connection
End Sub |
Partager