Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Where to declare ADODB connection
Message
 
To
26/06/2000 04:53:19
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Miscellaneous
Thread ID:
00384533
Message ID:
00384536
Views:
24
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 <><>
<><><><><><><><><><><><><><><><><><><><>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform