|
-
Jun 18th, 2003, 02:37 PM
#1
Thread Starter
Junior Member
Use multiple database
hi all,
I have the following problem. I'm making a program in VB 6.0. It's a program that has been developed without the use of any database.
At the start of the program a user has to define which database he wants to use (access-database). All databases available have the same constrution (tables and fields). Either he chooses it from a listview or a combobox. Depending on the database he chooses the connections to that database has to be done at runtime.
Is it possible to realise that and what kind of code do I have to write ?
-
Jun 18th, 2003, 03:04 PM
#2
Frenzied Member
If you are using ADO, then you can use this code to easily create your database connection at runtime. All you need to know is the path of the database and you're ready to go!
VB Code:
'In a module
Public cnn as New Adodb.Connection
'A function to open the connection, given the database location
Public Sub CreateConnection(strDatabasePath As String)
'Open the database connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strDatabasePath & _
";Persist Security Info=False"
End Sub
-
Jun 18th, 2003, 03:11 PM
#3
Thread Starter
Junior Member
thx,
If I know the path of de database can I just set
Public Sub CreateConnection(Database As String)
'Open the database connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\blabla\" & Database & _
".mdb;Persist Security Info=False"
End Sub
-
Jun 18th, 2003, 03:41 PM
#4
Frenzied Member
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
|