C# Sql Select Tutorial MS Access OleDb
In this C# tutorial, we will select users table from MS Access database file (mdb file) using C# code sample below.
C# SQL Select Code
using System.Data;
using System.Data.OleDb;
public DataSet GetUsersTable()
{
string constr =
"Provider=Data Source=yourmdbfile.mdb;provider=Microsoft.Jet.OLEDB.4.0";
string str_select = "SELECT * FROM tbl_users";
OleDbConnection con = new OleDbConnection(constr);
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(str_select, con);
da.Fill(ds);
return ds;
}
Note that you can also use this code sample in ASP.NET for access database.