Results 1 to 4 of 4

Thread: Use multiple database

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2003
    Location
    BELGIUM
    Posts
    24

    Arrow 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 ?


  2. #2
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545
    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:
    1. 'In a module
    2. Public cnn as New Adodb.Connection
    3.  
    4. 'A function to open the connection, given the database location
    5. Public Sub CreateConnection(strDatabasePath As String)
    6.     'Open the database connection
    7.     cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    8.             "Data Source=" & strDatabasePath & _
    9.             ";Persist Security Info=False"
    10. End Sub

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2003
    Location
    BELGIUM
    Posts
    24
    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

  4. #4
    Frenzied Member ae_jester's Avatar
    Join Date
    Jun 2001
    Location
    Kitchener Ontario Canada Earth
    Posts
    1,545
    yep

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width