Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft Access list all database

Tags:

c#

I need to fetch all databases of Microsoft Access in localhost.

On clicking the database name I have to list the tables

I can able to fetch the tables for a particular database.

My problem is I cant able to list out the MS Access databases available in localhost please suggest me the ideas to start coding

I tried

OleDbConnection con; // create connection 
OleDbCommand com; // create command     
OleDbDataReader dr; //Data read for read data from database 
con = new  OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0; Data Source =D:\mydb.mdb"); 
com = new  OleDbCommand("Select * from Table1",con); 
con.Open(); // open the connection dr =  com.ExecuteReader();

expected result:

with out mentioning Data Source =D:\mydb.mdb" i have to list all ms access databases of

localhost

All available databases like

database1.accdb
database2.accdb
like image 943
kala Avatar asked Nov 24 '25 01:11

kala


1 Answers

Access (or Jet, to use the name of the database engine) doesn't run a server, in the way that Sql Server or MySql do. An Access database is simply a file of particular format that is loaded on request, but the Jet engine libraries.

For this reason, there's no simple way to find all databases on a local machine: you would need to scan all files on the machine for .accdb or .mdb extensions. More likely, you should ask the user to select a specific file or scan a specified subfolder, since searching the whole machine will likely take a prohibitively long time.

like image 200
Dan Puzey Avatar answered Nov 26 '25 15:11

Dan Puzey



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!