Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ADODB.Connection and Class Modules
Message
De
22/08/2001 14:36:03
 
 
À
22/08/2001 14:01:06
Information générale
Forum:
Visual Basic
Catégorie:
Bases de données DAO/RDO/ODBC/ADO
Divers
Thread ID:
00547477
Message ID:
00547515
Vues:
11
>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

You probably need to pass a reference to the actual connection object from your class. You could do this if you expose a property and assign the connection object to it. Then on your code you can do something like:
rs.Open "Tablename", cn.ConnectionObject
HTH
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform