purplehaze1
Programmer
I am building class library (dll) that has 2 classes,eg. Login class & Vendor Class.
I build the connection string when the user logs in. I need to use this connection
string in vendor class to get all vendors information.
How can I make this connection string accessible to vendor class module (ideally to all class
modules. Similar to when you declare public variable in module, you can access it anywhere)?
Thanks for your help.
eg.
Public Class clsLogin
Private Server, userName, database, password as string
Private SQL_ConnectionString as string
Function Connect() As Boolean
Try
ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info = False;" & _
"Initial Catalog = " & database & ";Data Source = " & Server & ";User ID =" & userName & ";Password =" & password & ";"
myConnection = New OleDbConnection(ConnectionString)
myConnection.Open()
myConnectFlag = True
If myConnectFlag Then
SQL_ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info = False;" & _
"Initial Catalog =Payroll;Server=" & Server & ";User ID =" & userName & ";Password =" & password & ";"
End If
Return myConnectFlag
Catch e As Exception
Console.WriteLine(e.ToString())
End Try
End Function
End Class
I build the connection string when the user logs in. I need to use this connection
string in vendor class to get all vendors information.
How can I make this connection string accessible to vendor class module (ideally to all class
modules. Similar to when you declare public variable in module, you can access it anywhere)?
Thanks for your help.
eg.
Public Class clsLogin
Private Server, userName, database, password as string
Private SQL_ConnectionString as string
Function Connect() As Boolean
Try
ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info = False;" & _
"Initial Catalog = " & database & ";Data Source = " & Server & ";User ID =" & userName & ";Password =" & password & ";"
myConnection = New OleDbConnection(ConnectionString)
myConnection.Open()
myConnectFlag = True
If myConnectFlag Then
SQL_ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info = False;" & _
"Initial Catalog =Payroll;Server=" & Server & ";User ID =" & userName & ";Password =" & password & ";"
End If
Return myConnectFlag
Catch e As Exception
Console.WriteLine(e.ToString())
End Try
End Function
End Class