Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_components thread: Component to open db connection


Message #1 by "Louise" <lgreally@c...> on Tue, 20 Nov 2001 14:29:56
Hi



Im creating a very simple component which opens a connection to a database.

I wish to then create a new instance of this object, which will connect to 

the db in any of my other dll's that wish to access this database.  My 

question is which is the best way of passing out the connection object

eg



Private Const strConnection As String = "PROVIDER=MSDASQL;driver

{Microsoft Access Driver (*.mdb)};DBQ=C:\DB\customers.mdb"



Public Function OpenConnection() As Connection



' opens connection to database

Set db = New Connection



 db.CursorLocation = adUseClient

 db.Open strConnection

 OpenConnection = db



End function



Is the best way to retrieve this connection object in other dlls to use 

dim conn as connection 

set conn = myConnectionObj.OpenConnection ??



Im sure theres a more efficient way of doing this, can anyone point me in 

the right direction please??

  Return to Index