Hi Group
I apologize for this very basic (I guess) question. I had a look in
the posts and on MSDN but don't know where to start. I'm grateful for
any push in the right direction. I just don't know what I need to do.
Thank you so much!
Let's assume I've a procedure in class A which does some database
manipulation. When I run the procedure I want to open a SQL connection
and run some code. Since I have more than one procedure which opens a
connection, I don't want to write the code for opening a connection
all over again and I thought I put it in a separate class file B.
The class file B looks something like this:
Public Class clsData
Public Sub OpenSQLConectio n()
Dim SQLConnection As New System.Data.Sql Client.SqlConne ction
SQLConnection.C onnectionString = "workstatio n
id=THEINTREPIDF OX;packet size=4096;user id=sa;data
source=""(local )"";p" & _
"ersist security info=False;init ial catalog=Test"
SQLConnection.O pen()
End Sub
Public Sub CloseSQLConnect ion()
Dim SQLConnection As System.Data.Sql Client.SqlConne ction
SQLConnection.C lose()
End Sub
End Class
-------------------------------------------------------------------------------
The code for class A from which I call the open database procedure is:
Imports TestApplication .clsData
Public Class clsValidate
Public Sub DataManipulatio n()
'Open database connection
clsData.OpenSQL Connection()
...Run Code
'Close database connection
clsData.CloseSQ LConnection
End Sub
End Class
-------------------------------------------------------------------------------
How can I get the instance of the open connection so I can tell the
application under '...Run Code' that it shall use the connection being
opened in clsData?
How do I tell the CloseSQLConnect ion() procedure to close this very
open connection??
Apologies again for this simple question. I bet there are much more
errors in the code above. Please don't be too hard on me. :-)