Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to define global objects

Status
Not open for further replies.

oankaar

Programmer
Mar 19, 2002
3
GB
Hi all

I've just recently moved to .NET from VB6 and have a small question.

In VB6 I was able to create a global database connection object by defining it in a VB module. Example :

Public conn As ADODB.Connection

sub main()
Set conn = New ADODB.Connection
...
end sub

What I've done in .NET is create a connection class that takes a connection string and returns a connection object ( the idea is that I can use this class with any project to create a connection object). This works fine - what I need to know is how can I create a global object from this class - will I need to create a module and define it there or is there a better way? All examples I have seen involve creating a connection, adapter, dataset on each form.

Any help would be appreciated.

OM
 
Look at putting the connection in a Private SHARED variable in the Class and use a PUBLIC SHARED Function GetConn() as Connection to Return it. Yhe function can determine if it needs to be created. Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top