tags:

views:

60

answers:

2

Using vb6

I am Using MDI Form, In all the Form i need the database Connection, How to give connection is active for all the forms.

I want to write a common connection for all. Then I will call the connection for the forms whenever i needed.

Am new to MDI Form.

Need VB6 code Help.

A: 

you can define the connection object in Module and use it anywhere.

Wael Dalloul
A: 

In your MDI Form create a module level variable to hold the connection:

Private m_Conn as ADODB.Connection

Create a public property getter in the MDI Form:

Public Property Get CurrentConnection() as ADODB.Connection
     Set CurrentConnection = m_Conn
End Property

From your Child form, to get the MDI Form's connection (assuming MDI Form is named MainForm):

Dim oConn As ADODB.Connection

Set oConn = MainForm.CurrentConnection
C-Pound Guru