From this Post we are going to see how to bind the access db to the gridview. For this we have to take the OleDbConnection as a connection.
I Think above code is help you to understand the data binding of access to the grid.
OleDbConnection myConnection = default(OleDbConnection);
OleDbCommand myCommand = default(OleDbCommand);
string strSQL = null;
strSQL = "SELECT * FROM
tblLogin " + "WHERE
username=rajesh";
myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
" + "Data
Source="
+ Server.MapPath("login.mdb") + ";");
myConnection.Open();
myCommand = new OleDbCommand(strSQL, myConnection);
OleDbDataAdapter adp=new OledbDataAdapter(myCommand);
dataset ds=new dataset();
adp.fill(ds);
gridview.datasource=ds;
gridview.databind();
No comments:
Post a Comment