Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Where to declare ADODB connection
Message
 
À
29/06/2000 21:53:25
Information générale
Forum:
Visual Basic
Catégorie:
Bases de données DAO/RDO/ODBC/ADO
Divers
Thread ID:
00384533
Message ID:
00387289
Vues:
17
I think, if you didn't declare it as public... you can't call it in the project
"Startup Object" ,"Sub Main"


>I tried your method and it works. Thanks alot.
>But I have a query. Is it neccessary to declare the Sub Main() as Public?
>Since the Conn already declare as Public variable. Pls advise, thanks.
>
>>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
Répondre
Fil
Voir

Click here to load this message in the networking platform