Other
//To Connect Access file first of all you have to define connection string
string ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Database1.mdb";
// Initialize the instance of OleDB Connection class which can connect multiple types of databases
OleDbConnection MyConn = new OleDbConnection(ConnStr);
// Open the connection
MyConn.Open();
// define a string for the SQL Code
string MyQuery = "Select ID, MyName, Sallary From Employee";
// initialize Command class instance
OleDbCommand MyComm = new OleDbCommand(MyQuery, MyConn);
//DataTable instanec can be as a datasource or holder for the information retrived from the source
DataTable MyTable = new DataTable();
// The adapter used fill method to fill data into data table instance
OleDbDa
c#
代码
access
数据库
检索
使用
数据
No comment