Message 1 of 3
AutoCAD 2002 VBA & MS Access 97: Run-time error'3706'- Provider cannot be
Not applicable
03-25-2002
11:03 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
The following VBA program codes ran OK in the VBA of AutoCAD R14.01 before, but not in the VBA of AutoCAD 2002 that generated "Run-time error'3706'- Provider cannot be found":
Public Sub CreateCircles()
' Connect to the database using ADO and read
' coordinate data out of it to produce the
' drawing
Dim conServer As ADODB.Connection
Dim rstCircle As ADODB.Recordset
Dim rstMetaData As ADODB.Recordset
Dim cir As AcadCircle
Dim ptCenter(0 To 2) As Double
Dim vecNormal(0 To 2) As Double
' Connect to the data source
Set conServer = New Connection
With conServer
.ConnectionString = "Provider=Microsoft.Jet.OLEDB4.0;" _
& "Data Source=C:\AppDev\VBA Solu\Chapter4.mdb"
' We don't need to be able to do anything but read data
.Mode = adModeRead
.Open
End With
' Now retrieve the records
Set rstMetaData = New ADODB.Recordset
With rstMetaData
.Source = "SELECT * FROM tblCircle"
.ActiveConnection = conServer
.Open
' Create a circle object for each record
Do Until .EOF
' Find the center and make the circle
ptCenter(0) = !CenterX
ptCenter(1) = !CenterY
ptCenter(2) = !CenterZ
Set cir = ThisDrawing.ModelSpace. _
AddCircle(ptCenter, !Radius)
' Rotate the circle to match the
' supplied normal vector
vecNormal(0) = !NormalX
vecNormal(1) = !NormalY
vecNormal(2) = !NormalZ
cir.Normal = vecNormal
' Set the color
cir.Color = !Color
' And draw it
cir.Update
.MoveNext
Loop
.Close
End With
' Free the connection to the server
conServer.Close
Set cir = Nothing
End Sub
================================
I have tried to set up the OLE DB configuration in my AutoCAD 2002 References without success: (1) If I have "Microsoft OLEDB Service Component 1.0 Type Library" and "OLE Automation" checked in the References of the Tools menu, I got "Run-time error '3706' all the times. (2) If I have "Microsoft OLE DB Simple Provider 1.5 Library" checked, then I got "Microsoft Visual Basic Error in loading DLL". I am a new VBA user and do not know what is wrong in the AutoCAD 2002 VBA programming that used ADO or OLE DB to get MS Access 97 data - The MS Access 97 is on the Microsoft 2000 built on NT Technology. Please help and tell me how to solve this problem.
Thanks in advance,
Scott Chang
The following VBA program codes ran OK in the VBA of AutoCAD R14.01 before, but not in the VBA of AutoCAD 2002 that generated "Run-time error'3706'- Provider cannot be found":
Public Sub CreateCircles()
' Connect to the database using ADO and read
' coordinate data out of it to produce the
' drawing
Dim conServer As ADODB.Connection
Dim rstCircle As ADODB.Recordset
Dim rstMetaData As ADODB.Recordset
Dim cir As AcadCircle
Dim ptCenter(0 To 2) As Double
Dim vecNormal(0 To 2) As Double
' Connect to the data source
Set conServer = New Connection
With conServer
.ConnectionString = "Provider=Microsoft.Jet.OLEDB4.0;" _
& "Data Source=C:\AppDev\VBA Solu\Chapter4.mdb"
' We don't need to be able to do anything but read data
.Mode = adModeRead
.Open
End With
' Now retrieve the records
Set rstMetaData = New ADODB.Recordset
With rstMetaData
.Source = "SELECT * FROM tblCircle"
.ActiveConnection = conServer
.Open
' Create a circle object for each record
Do Until .EOF
' Find the center and make the circle
ptCenter(0) = !CenterX
ptCenter(1) = !CenterY
ptCenter(2) = !CenterZ
Set cir = ThisDrawing.ModelSpace. _
AddCircle(ptCenter, !Radius)
' Rotate the circle to match the
' supplied normal vector
vecNormal(0) = !NormalX
vecNormal(1) = !NormalY
vecNormal(2) = !NormalZ
cir.Normal = vecNormal
' Set the color
cir.Color = !Color
' And draw it
cir.Update
.MoveNext
Loop
.Close
End With
' Free the connection to the server
conServer.Close
Set cir = Nothing
End Sub
================================
I have tried to set up the OLE DB configuration in my AutoCAD 2002 References without success: (1) If I have "Microsoft OLEDB Service Component 1.0 Type Library" and "OLE Automation" checked in the References of the Tools menu, I got "Run-time error '3706' all the times. (2) If I have "Microsoft OLE DB Simple Provider 1.5 Library" checked, then I got "Microsoft Visual Basic Error in loading DLL". I am a new VBA user and do not know what is wrong in the AutoCAD 2002 VBA programming that used ADO or OLE DB to get MS Access 97 data - The MS Access 97 is on the Microsoft 2000 built on NT Technology. Please help and tell me how to solve this problem.
Thanks in advance,
Scott Chang