This program for fetch data from microsoft access database
Step 1) Add below code in your ASP.Net page
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();
}
}
No comments:
Post a Comment