Fetch data from microsoft Access using C#

Sourav.Kayal
Posted by Sourav.Kayal under C# category on | Points: 40 | Views : 2100
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data;
using System.Data.SqlClient;
using System.Data.Odbc;
using System.Data.OleDb;

public partial class oledb : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{


OleDbConnection objConn = new OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=D:\\mydb.mdb;");

OleDbCommand objCmd = new OleDbCommand("select * from stud", objConn);
OleDbDataReader objReader;
objConn.Open();
objReader = objCmd.ExecuteReader();

while (objReader.Read())
{
Response.Write(objReader.GetValue(1));
Response.Write(objReader.GetValue(2) + "<br>");
}
objConn.Close();


}
}

Comments or Responses

Login to post response