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.
Re: how to add independent Access Data Source
Quote:
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 ;) )
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)