Sample codes – AutoCAD VBA and *.mdb database
Insert data into the table “Table1”
First of all, add the reference (Microsoft ActiveX Data Objects 2.8 Library) to the project – My Auto-CAD Version 2007 – as shown below
This Project assumes, you have data in 3 text boxes and need to insert those into the Table1 & Fields D1, S1 and T2
Code begines
Insert data into the table “Table1”
First of all, add the reference (Microsoft ActiveX Data Objects 2.8 Library) to the project – My Auto-CAD Version 2007 – as shown below
This Project assumes, you have data in 3 text boxes and need to insert those into the Table1 & Fields D1, S1 and T2
Code begines
Code:
Dim commandstring as string
Dim databasepath as string
databasepath = “E:\DATABASE.mdb”
Dim connection1 As New ADODB.Connection
Dim command1 As New ADODB.Command
commandstring = “INSERT INTO Table1(D1,S1,T2) VALUES(‘” & Me.TextBox1.Text & “‘,'” & CDbl(Me.TextBox2.Text) & “‘,'” & CDbl(Me.TextBox3.Text) & “‘)”
connection1 .Open “Provider=Microsoft.Jet.OLEDB.4.0;Data Source=” &
databasepath & “; Jet OLEDB:Database Password=;”
command1.ActiveConnection = connection1
command1.CommandText = commandstring
command1.Execute
connection1.Close