Downloading data from MySQL database in Excel sheet
To start the download from the MySQL database, you must initiate connection with the database in Excel.
Enter the joining question in one of the cells of the sheet. A prerequisite is installation
ODBC data sources on the system. To this end, we must first install our database in the Data Source Administrator.
Then we refer to it in the question "Questionlacz" where we give the created DSN or the name of the database link from ODBC
database, database server and password.
Sheets("sql komputery").Select
'connecting to base
'Range("B5").Select
'Pytanielacz = ActiveCell.Text
Pytanielacz = "DSN=BOCAR2;DATABASE=bocar_wkp;SERVER=marixxx.iq.pl;UID=bocar_wkp;PWD=xxxxxxxxx"
' connection ADO
Dim cnn As New ADODB.Connection
Dim rst As ADODB.Recordset
Dim cmd As ADODB.Command
Dim i, j As Integer
' Opening a connection
Set cnn = New Connection
cnn.Open "DRIVER={MariaDB ODBC 3.1 Driver};" & Pytanielacz
For testing you will need to call the MsgBox modal window.
'MsgBox "Connection successful", , "VBATools.pl"
Best Aplications