|
-
Jul 17th, 2007, 12:35 PM
#1
Thread Starter
New Member
how to give common Database connection for different forms in an application.
I am new to programming this is my first application.Please help me .
I use this code for connecting to database.
Public Sub setConnection1(ByVal ConnectionStr As String, Optional ByVal Provider As String = "System.Data.Odbc")
' Allows for changeing database 'command' provided type: SqlClient, Odbc, Ole
Console.WriteLine(ConnectionStr)
Dim DBFactory As Common.DbProviderFactory = Common.DbProviderFactories.GetFactory(Provider)
Cmd = DBFactory.CreateCommand
Cmd.Connection = DBFactory.CreateConnection()
Cmd.Connection.ConnectionString = ConnectionStr
End Sub
i use this statment in Login form.
setConnection("ODBC;DATABASE=xxx;UID='" xxxx "';PWD='" xxx& "';DSN=xxx")
I have 6 forms in my application so it connects 6 times to database . how can i make a common connection. Please help me.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|