J'utilise un code pour modifier ma base de donnée mais sans succès ou réaction de Visual basic :
Function Connection()
Dim source As String, location As String, user As String, password As String, mysql_driver As String, database As String
Dim requete As String
source = "MySQL"
location = "localhost"
user = "root"
password = ""
database = "monsite"
mysql_driver = "MySQL ODBC 8.0 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)
requete = " CREATE DATABASE IF NOT EXISTS `vbamysql` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;" & _
"USE `vbamysql`;" & _
"CREATE TABLE IF NOT EXISTS `voitures` (" & _
"`id` INTEGER NOT NULL auto_increment," & _
"`marque` VARCHAR(25) NOT NULL," & _
"`modele` VARCHAR(25) NOT NULL ," & _
"`cv` INTEGER," & vbCrLf & _
"PRIMARY KEY (`id`)," & _
"UNIQUE (`modele`)" & _
") ENGINE = InnoDB ;"
End Function
Sub Macro1()
Connection
End Sub