I am trying to set up a function that connects to the database that I can
then use gloablly. I set up a class called L3Global in which I have a
function as follows:
Public Function SetDBConnect()
Dim ConnStrL3Produc er As String
ConnStrL3Produc er = "User ID=UID;Tag with column collation when
possible=False; Data Source=" & Chr(34) & "a.b.c.d" & Chr(34) &
";Password=PWD; "
ConnStrL3Produc er = ConnStrL3Produc er & "Initial Catalog=L3;Use Procedure
for Prepare=1;Auto Translate=True; Persist Security Info=True;Provi der="
ConnStrL3Produc er = ConnStrL3Produc er & Chr(34) & "SQLOLEDB.1 " & Chr(34) &
";Workstati on ID=AUM;Use Encryption for Data=False;Pack et Size=4096"
Dim ConnL3Producer As New OleDbConnection (ConnStrL3Produ cer)
Return ConnL3Producer
End Function
Now I want to use this is all my forms (MDI). I set up
Public L3G As New L3Global
and then under the approporate button click I have:
Dim ConnL3Producer As New OleDbConnection
ConnL3Producer = L3G.SetDBConnec t
The problem is, do I have to setup an instance of L3Global in each form?
That defeats the purpose, because each one opens a new connection. How can
I use this connection object in all my forms but open it only once? Ideally
I would like to move as much of the intialization (creating the OLEDBAdapter
etc) to the global routine.
Thanx for any suggestions.
--
Anil Gupte
www.icinema.com
then use gloablly. I set up a class called L3Global in which I have a
function as follows:
Public Function SetDBConnect()
Dim ConnStrL3Produc er As String
ConnStrL3Produc er = "User ID=UID;Tag with column collation when
possible=False; Data Source=" & Chr(34) & "a.b.c.d" & Chr(34) &
";Password=PWD; "
ConnStrL3Produc er = ConnStrL3Produc er & "Initial Catalog=L3;Use Procedure
for Prepare=1;Auto Translate=True; Persist Security Info=True;Provi der="
ConnStrL3Produc er = ConnStrL3Produc er & Chr(34) & "SQLOLEDB.1 " & Chr(34) &
";Workstati on ID=AUM;Use Encryption for Data=False;Pack et Size=4096"
Dim ConnL3Producer As New OleDbConnection (ConnStrL3Produ cer)
Return ConnL3Producer
End Function
Now I want to use this is all my forms (MDI). I set up
Public L3G As New L3Global
and then under the approporate button click I have:
Dim ConnL3Producer As New OleDbConnection
ConnL3Producer = L3G.SetDBConnec t
The problem is, do I have to setup an instance of L3Global in each form?
That defeats the purpose, because each one opens a new connection. How can
I use this connection object in all my forms but open it only once? Ideally
I would like to move as much of the intialization (creating the OLEDBAdapter
etc) to the global routine.
Thanx for any suggestions.
--
Anil Gupte
www.icinema.com
Comment