CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2011
    Posts
    1

    Load or Connect to DB Dialog VB 2010

    Does anyone know if you can create a dialog on the vb form to connect to a ms access 2007 db locally?

    I am creating a app to analyze databases for duplicate data for multiple projects. For example, I might have 10 different access databases to analyze individually and I would like to choose them from a dialog control if possible. After the connection is made I will then proceed to run the query from the button click event and spit out the resulting data into a separate winform.

    I am not sure if a openfiledialog could be used but any direction to tutorials, etc. would help.

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Load or Connect to DB Dialog VB 2010

    You can use a FILEDIALOG to choose the table to use, but there isn't an easy way to open a connection to each table, or even run a query. You can use Access to do that, though
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Load or Connect to DB Dialog VB 2010

    Openfiledialog should work fine. You just need to get the filename from the dialog and modify your connection string accordingly with the selected filename then open the db as usual.

    Been a while since I tried to check out the structure of a mdb via vb but if memory serves there used to be a way to access the collection of tables in the db and you could retrieve the names and other properties of the tables.
    Always use [code][/code] tags when posting code.

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Load or Connect to DB Dialog VB 2010

    LINQ to SQL should work
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Load or Connect to DB Dialog VB 2010

    Quote Originally Posted by dglienna View Post
    LINQ to SQL should work
    To browse to an Access database?

    I was refering to the old DAO methods before, not sure if any of those carried over into ADO or ADO.Net Some of the DAO features were very useful like the seek function on the table object for example was extremely fast once the table had been loaded.

    Sounds like the OP just needs to change the active database and if so a file dialog is all that is needed.
    Always use [code][/code] tags when posting code.

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Load or Connect to DB Dialog VB 2010

    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Tags for this Thread

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

Featured