<% @ Page language = "c #" contenttype = "text / html" responseEncoding = "gb2312"%>
void Page_Load () {string DB_name = "dbTest.mdb"; string DB_path = Server.MapPath (DB_name); string SQL = "SELECT [CategoryID], [CategoryName] FROM [Categories]"; string connectionString = @ "Provider = Microsoft .Jet.OLEDB.4.0; Ole DB Services = -4; Data Source = " DB_path; // establish OleDbConnection System.Data.IDbConnection dbConnection = new System.Data.OleDb.OleDbConnection (connectionString); // establish OleDbCommand System. Data.IDbCommand dbCommand = new System.Data.OleDb.OleDbCommand (); dbCommand.CommandText = SQL; dbCommand.Connection = dbConnection; // establish DataSet System.Data.DataSet dbSet = new System.Data.DataSet (); // establishing OleDbDataAdapter System.Data.IDbDataAdapter dbAdapter = new System.Data.OleDb.OleDbDataAdapter (); dbAdapter.SelectCommand = dbCommand; // select OleDbCommand dbAdapter.Fill (dbSet); // filled DataSet
// DataGrid control operation DataGrid1.datasource = dbset; // Data source dataGrid1.database (); // Pressing data} script>