Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection String of ms access database 2010 in c# for dns less

Friends... Since,

 OleDbConnection vcon = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;
 Data Source=C:\Users\Tushar\Documents\db.accdb");

This string use in c# for ms access database connection..see database location already known and it works..

But, I want to run application when database in any location ...(i.e) it should take database location Automatically from any location( when user save project in any location)

Can some buddy help me..

Thanks in Advance..

like image 789
Tushar Wakchaure Avatar asked Feb 01 '26 22:02

Tushar Wakchaure


1 Answers

I suggest creating the logic in C# to determine where the DB is. Once you know, it's as simple as string concatenation:

var dbLocation = GetDbLocation();
OleDbConnection vcon = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;
                              Data Source=" + dbLocation ");

GetDbLocation() could pull the information from a config file, or determine it in some other way (you haven't given us enough information to determine where the DB is located).

like image 150
James Hill Avatar answered Feb 03 '26 11:02

James Hill



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!