how to attach acces file to project in visualstudio 2003

hello
can anyone help me to attach acces file to project becouse now when i change location of project, my project stop working becouse it has to be in same place where it was when i was adding a connection. I want to be able to change location of application and mdb file without any problems
thank a lot
arek


Answer this question

how to attach acces file to project in visualstudio 2003

  • Tony Deady

    ir was really helpfull
    thanks a lot
    arek

  • Leow Kah Man

    Maybe you can try generating the path part of your connection string using configuration file, or let the user browse for the database file, or put the database file in the project folder and use relative path.

  • MikkoL

    In case you are using an ASP.NET project you should copy your acces file to the App_data folder.

    If it's a Windows Forms app you can change the path to use referenced path names: instead of writing C:\..\...\file.mdb, you can do ./file.mdb

    Kind regards,
    Bjorn


  • Linda Li

    Arek,

    In .Net 2.0, we introduced the concept of Substituion string, which allows you to add Relative paths for AttachDbFileName. Look up http://blogs.msdn.com/dataaccess/archive/2005/10/28/486273.aspx for more details.

    Hope this helps.



  • Maximus5150

    Arek,

    While developing applications it is always a good thing decoupling your application with other sources (data sources - in this case your data source is access mdf file).
    I guess your were using a new connection wizard and hardcoded your connection string into your project and so coupled your application with mdf file. To avoid such coupling simply specify your connection string in config file and assign value on initialization.

  • how to attach acces file to project in visualstudio 2003