Question about Visual Studio 2005 Dataset and Microsoft Access RRS feed

  • Question

  • Dear guys,

    I was trying to use Visual Studio 2005 dataset with Microsoft Access as the data source. Everything was fine until I try to deploy the application to another computer. It look like my application still refer my mdb database to my local computer path. Earlier when creating the dataset, I already chosed "Yes" when prompted to copy the mdb file to my project directory. What have I missed?


    Many thanks and regards

    Thursday, January 12, 2006 8:57 AM

All replies

  • How have you created your connection string?  Does it still refer to the absolute path on your development machine?  If you are going to have your database in your program folder, which is not the best idea in my opinion, then I'd say that the best thing to do would be to create your connection string at run time and use Application.StartupPath to refer to the program folder no matter where it is.
    Thursday, January 12, 2006 2:19 PM
  • @jmcilhinney

    Thank you for replying. I'm creating the dataset with Visual Studio 2005 connection wizard. From what I read in MSDN, it's easy to retrieve and manipulate database using the new feature of dataset. Just few click and drag and drop.The connection string was read only and refer to path where I browse for the mdb file or my local project directory. Maybe I should just stick to the old fashioned way :(




    Friday, January 13, 2006 2:36 AM
  • When you do it the way you have I think you'll find that the connection string is stored in the config file.  When you install to a different location, you can either edit the config file by hand or, more likely, provide a facility in your application to do so in code.  If you're using the program folder then simply have your app create a new connection string if the current one doesn't work.  You can use Application.StartupPath to build the new connection string and save it to the config file.
    Friday, January 13, 2006 2:58 AM
  • If so, I would prefer open the connection in old way. Create the connection object, provide the connection string, and then open the connection by code.

    IMHO, they should mention that in MSDN when they wrote "How TO or Walkthrough".

    Friday, January 13, 2006 3:19 AM