AutoCAD 2002 VBA & MS Access 97: Run-time error'3706'- Provider cannot be

AutoCAD 2002 VBA & MS Access 97: Run-time error'3706'- Provider cannot be

Anonymous
Not applicable
830 Views
2 Replies
Message 1 of 3

AutoCAD 2002 VBA & MS Access 97: Run-time error'3706'- Provider cannot be

Anonymous
Not applicable
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
0 Likes
831 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Change:

Provider=Microsoft.Jet.OLEDB4.0;"

to:

Provider=Microsoft.Jet.OLEDB.4.0;"

--
Veign
www.veign.com
Code Samples & Sample Projects
http://www.veign.com/information/application/info_app.html
---------
"shc" wrote in message
news:[email protected]...
> 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
>
>
0 Likes
Message 3 of 3

Anonymous
Not applicable
In addition to the change noted by Veign, add ";Persist Security
Info=False" onto the end of your connection string.

The only reference you need in your VB project is "Microsoft ActiveX
Data Objects 2.7 Library" (the version number may be different on your
system).

--
jrf
Member of the Autodesk Discussion Forum Moderator Program
Please do not email questions unless you wish to hire my services

In article , Shc wrote:
> 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
>
0 Likes