Quantcast
Channel: put mdb file list in dropdownlist from a folder
Viewing all articles
Browse latest Browse all 20

Re: put mdb file list in dropdownlist from a folder

$
0
0

Are you saying that you don't know the names of the tables in the database? If so, you can use OleDb.GetSchema to get a list of all the tables:

using(var conn = new System.Data.OleDb.OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=path_to_your_database.mdb"))
using(var cmd = new System.Data.OleDb.OleDbCommand())
{
    cmd.Connection = conn;
    conn.Open();
    var dt = conn.GetSchema("Tables");

    foreach(DataRow row in dt.Rows)
    {
        if(row["TABLE_TYPE"].ToString() == "TABLE")
        {
            // add the value to your dropdown
	}
    }
}


Viewing all articles
Browse latest Browse all 20

Trending Articles