This page creates a table, a button, a text box, enter an index number in the text box, click the button. Display the corresponding record content in the table, if it is not displayed. This table reads the database correctly. Mainly a small example.
File name: Test_1.aspx
<% @ Page language = "c #" debug = true%>
// Insert Page Code Here //
System.Data.DataSet MyQueryMethod (int ID) {string connectionString = "provider = microsoft.jet.Oledb.4.0; Ole DB Services = -4; Data Source = E: // wwwroot // ADAT" "a.mdb" System.Data.idbconnection dbconnection = new system.data.oledb.oledbconnection (connectionString);
String queryString = "SELECT [One]. * from [one] where ([one]. [ID] = @ID)"; system.data.idbcommand dbcommand = new system.data.oledb.oledbcommand (); dbcommand.comMandText = queryString; dbcommand.connection = dbconnection;
System.Data.IDataParameter dbParam_id = new System.Data.OleDb.OleDbParameter (); dbParam_id.ParameterName = "@id"; dbParam_id.Value = id; dbParam_id.DbType = System.Data.DbType.Int32; dbCommand.Parameters.Add (dbparam_id);
System.Data.IDbDataAdapter dataAdapter = new System.Data.OleDb.OleDbDataAdapter (); dataAdapter.SelectCommand = dbCommand; System.Data.DataSet dataSet = new System.Data.DataSet (); dataAdapter.Fill (dataSet);
Return DataSet;
void Button1_Click (object sender, EventArgs e) {//DataGrid1.DataSource = GetOrderDetails (CInt (TextBox1.Text)); //DataGrid1.DataSource = GetOrderDetails (Convert.ToInt32 (TextBox1.Text)); DataGrid1.DataSource = MyQueryMethod ( INT.PARSE (TEXTBOX1.TEXT)); DataGrid1.Database ();} script>