CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2005
    Posts
    74

    how to add independent Access Data Source

    Hi All,

    I get Data Source problem. My Access database is under Debug folder. When I move this project to another Drive or other machine, I need to change that Data Source again. I don't want to do it. I use Typed Dataset.


    for example:

    Data Source = D:\TestForDMOTable\TestForDMOTable\bin\Debug\DMO.mdb

    TO

    Data Source =E:\Implementation\Tutition\Team\ToTake\DMO_Thesis\TestForDMOTable\TestForDMOTable\bin\Debug


    I'd like to make the Data Source of Data Set for Microsoft Access that don't depend on the Access file Location path. Pls share me how to.

  2. #2
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: how to add independent Access Data Source

    Quote Originally Posted by soclose View Post
    Hi All,

    I get Data Source problem. My Access database is under Debug folder. When I move this project to another Drive or other machine, I need to change that Data Source again. I don't want to do it. I use Typed Dataset.


    for example:

    Data Source = D:\TestForDMOTable\TestForDMOTable\bin\Debug\DMO.mdb

    TO

    Data Source =E:\Implementation\Tutition\Team\ToTake\DMO_Thesis\TestForDMOTable\TestForDMOTable\bin\Debug


    I'd like to make the Data Source of Data Set for Microsoft Access that don't depend on the Access file Location path. Pls share me how to.
    There are two different options. One is to have it in the application path and simple pointing to that path so it is found by the program automatically.
    Code:
    string path = @AppDomain.CurrentDomain.BaseDirectory + @"\mydatabaseName.mdb";
    The other way which I personally prefer is to have a setup where I have the adress and if you change the database location simple change that setup entry and it will find it, where ever you have placed it.
    Code:
    path = Properties.Settings.Default.MyDatabasePath:
    (In the settings you need to declare your path )
    Last edited by JonnyPoet; June 27th, 2009 at 05:39 AM.
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  3. #3
    Join Date
    Jan 2005
    Posts
    74

    Re: how to add independent Access Data Source

    Thanks JonnyPoet.

    However my problem is happened at connection string of TableAdapter Configuration Wizard whenever I move my project. I added those codes u described me are used when coding OleDbConnection. But I use TableAdapter.Update.

    For example,
    FieldofTableTableAdapter adptFT = new FieldofTableTableAdapter();
    adptFT.Connection.ConnectionString = db.conStr;
    if (adptFT.Update(ds.FieldofTable) > 0)

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