Message 1 of 9
Not applicable
05-15-2019
12:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Please, i'm looking to connect Inventor Professionnal 2019 to a DATABASE in MySQL 8.0 using a VBA code.
i maked some tests in Excel and it works.
but it doesn't work using the same Code in VBA editor of Inventor.
i cheked the reference of the editor. their are the sames in Excel. So i don't know how resolve the problem.
this is my VBA code :
Private Sub CommandButton1_Click()
UserForm
End Sub
Private Sub UserForm()
Dim Cn As ADODB.Connection
Dim Server_Name As String
Dim Database_Name As String
Dim User_ID As String
Dim Password As String
Dim SQLStr As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim Num As String
Server_Name = "127.0.0.1"
Database_Name = "base"
User_ID = "root"
Password = "m02pas"
Num = TextBox1.Value
SQLStr = "SELECT numero FROM table01 WHERE numero LIKE '" & Num & "%'"
Set Cn = New ADODB.Connection
Cn.Open "Driver={MYSQL ODBC 8.0 Unicode Driver};Server=" & Server_Name & ";Database=" & Database_Name & ";Uid=" & User_ID & ";Pwd=" & Password & ";"
rs.Open SQLStr, Cn, adOpenStatic
a = rs.GetRows
ListBox1.ColumnCount = UBound(a, 1) + 1
ListBox1.List = Application.Transpose(a)
rs.Close
Set rs = Nothing
Cn.Close
Set Cn = Nothing
End Sub
Private Sub CommandButton2_Click()
Unload UserForm1
End Sub
Thank you.
Solved! Go to Solution.