Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADODB.Connection and Class Modules
Message
From
22/08/2001 14:01:06
 
 
To
All
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Title:
ADODB.Connection and Class Modules
Miscellaneous
Thread ID:
00547477
Message ID:
00547477
Views:
28
I work with FoxPro, Access and SQL databases. When I write programs I need to determine at run time what the database I am working with is and then create the connection based on the database. I decided to create a Class Module to create the connection. I created a property called DataBase and depending upon which database it is the appropriate driver is used and the connection is opened.

It seems to be working ok. I can test for the state of the connection and it will be open. The problem I am running into is when I try to use the connection to open an ADODB.Recordset I am getting Error # 3001: Arguments are of the wrong type, out of acceptable range or in conflict with each other.

Example Code:

Dim cn as DataConnect 'Class Module - set as MultiUse
Dim rs as ADODB.Recordset

Set cn = New DataConnect

'Set the database type and path
cn.database = "access"
cn.datapath = "c:\test\test.mdb"

'Open connection return True if success
If cn.open_connection = False Then
MsgBox "Connection not Created."
Else
'if successful open then open recordset
rs.open "TableName", cn
End If

-------

Is it possible to use a Class Module with ADODB.Connection? Is cn not considered an ActiveConnection because it is a class module?

Thanks,

Nichole
Next
Reply
Map
View

Click here to load this message in the networking platform