-
June 27th, 2009, 05:24 AM
#1
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.
-
June 27th, 2009, 05:35 AM
#2
Re: how to add independent Access Data Source
Originally Posted by soclose
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
-
June 27th, 2009, 06:01 AM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|