BrotherLouis
New Member
- Joined
- Dec 5, 2018
- Messages
- 5
Hi,
I'm new Userform and when the form activate a dropdown list must be populate. I can't get my project to connect to the SQL database. With all my searches I found these code but I have no idea where to place these code. I have tried to place them in Userform activate but I get an error. Can someone please direct me urgently.
Private Sub ConnectDB()
Set oConn = New ADODB.Connection
oConn.Open "DRIVER={MySQL ODBC 5.1 Driver};" & _
"SERVER=localhost;" & _
"DATABASE=yourdatabase;" & _
"USER=yourdbusername;" & _
"PASSWORD=yourdbpassword;" & _
"Option=3"
End Sub
I'm new Userform and when the form activate a dropdown list must be populate. I can't get my project to connect to the SQL database. With all my searches I found these code but I have no idea where to place these code. I have tried to place them in Userform activate but I get an error. Can someone please direct me urgently.
Private Sub ConnectDB()
Set oConn = New ADODB.Connection
oConn.Open "DRIVER={MySQL ODBC 5.1 Driver};" & _
"SERVER=localhost;" & _
"DATABASE=yourdatabase;" & _
"USER=yourdbusername;" & _
"PASSWORD=yourdbpassword;" & _
"Option=3"
End Sub