Use OleDBCommand to read data returned from a select statement (C#) : OleDBCommand « ADO.net Database « ASP.NET Tutorial






<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script runat="server">
   void Page_Load(Object Sender, EventArgs e) {
      OleDbConnection objConn = new OleDbConnection(
      "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" +
       Server.MapPath("EmployeeDatabase.mdb;"));
      
      OleDbCommand objCmd = new OleDbCommand("select * from employee", objConn);

      OleDbDataReader objReader;
      
      objConn.Open();
      objReader = objCmd.ExecuteReader();
      
      while (objReader.Read()) {
         Response.Write(objReader.GetInt32(0) + "<br>");
      }
      objConn.Close();
   }
</script>

<html><body>

</body></html>








18.12.OleDBCommand
18.12.1.Use OleDBCommand to read data returned from a select statement (C#)
18.12.2.Pass OleDbParameter to OleDbCommand (VB.net)
18.12.3.Call stored procedure and pass in parameters (VB.net)
18.12.4.Execcute delete statement
18.12.5.Create OleDbDataReader object from OleDbCommand