Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Where to declare ADODB connection
Message
 
À
26/06/2000 04:53:19
Information générale
Forum:
Visual Basic
Catégorie:
Bases de données DAO/RDO/ODBC/ADO
Divers
Thread ID:
00384533
Message ID:
00384536
Vues:
27
Create a "Module" and make the connection public, and then make a "Public Sub Main()" in the same Module

Maybe this code will help

Option Explicit
Public Conn As ADODB.Connection

Public Sub Main()
'This will open a global connection
Set Conn = New ADODB.Connection
With Conn
'Change the data source property in the following line
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\temp\data\chamber.mdb;Persist Security Info=False"
.Open
End With
End Sub

Then chnge the "project properties", "Startup Object" to "Sub Main"
this should work.

Hope this help.




>I would like to declare a common connection to Database so that
>I could use it at any part of my forms, etc.
>
>I have a MDI Form and all other forms are child of the MDI Form.
>I tried to declare a Public cnn1 As ADODB.Connection at the
>MDI Load form portion and also tried at the Sub Main() there.
>
>But I still get the error message saying that trying to open
>a close connection. Any suggestions?
<><><><><><><><><><><><><><><><><><><><>
<><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
<><><><><><><><><><><><><><><><><><><><>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform