Pages

Monday, October 13, 2008

Connecting to access database

This code shows you how to connect to a access database



Using System.Data.SqlClient;


////////////////////////

OleDbConnection objConn = new OldDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=c:\\path\database.mdb");
OleDbCommand objCmd = new OleDbCommand("select * from employees",objConn);
objConn.Open();
OleDbReade objRdr = objCmd.ExecuteReader();

while(objRdr.Read())
{
Response.Write(objRdr["Name"] + "
");
}

objRdr.Close();
objConn.Close();
/////////////////////////

0 comments: