ESTABLISHING A CONNETION TO THE ACCESS DATABASE :
OleDbConnection connection= new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; " + "Data Source=" + Server.MapPath("PATH OF THE ACCESS DATABASE"));
OleDbCommand command = new OleDbCommand();
command .CommandText = "TYPE YOUR SQL QUERY HERE";
command .CommandType = CommandType.Text;
command .Connection = connection;
connection.Open();
command .ExecuteNonQuery();
connection.Close();
----------------------------------------------------------------------------------------------------------
BINDING THE DATA CONTROL WITH ACCESS DATABASE :
OleDbConnection connection= new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; " + "Data Source=" + Server.MapPath("App_Data/Database1.accdb"));
OleDbCommand command = new OleDbCommand("Select * FROM Table_Detail", conn);
connection.Open();
OleDbDataReader reader = command .ExecuteReader();
GridView1.DataSource = reader;
GridView1.DataBind();
connection.Close();
OleDbConnection connection= new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; " + "Data Source=" + Server.MapPath("PATH OF THE ACCESS DATABASE"));
OleDbCommand command = new OleDbCommand();
command .CommandText = "TYPE YOUR SQL QUERY HERE";
command .CommandType = CommandType.Text;
command .Connection = connection;
connection.Open();
command .ExecuteNonQuery();
connection.Close();
----------------------------------------------------------------------------------------------------------
BINDING THE DATA CONTROL WITH ACCESS DATABASE :
OleDbConnection connection= new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; " + "Data Source=" + Server.MapPath("App_Data/Database1.accdb"));
OleDbCommand command = new OleDbCommand("Select * FROM Table_Detail", conn);
connection.Open();
OleDbDataReader reader = command .ExecuteReader();
GridView1.DataSource = reader;
GridView1.DataBind();
connection.Close();
No comments:
Post a Comment