Write a Window application in C# that read employee recordfrom Microsoft access
ID: 3612135 • Letter: W
Question
Write a Window application in C# that read employee recordfrom Microsoft access database using odbc (Open DatabaseConnectivity). Your application would retrieve the employeerecords i.e. Employee id, name, address and age anddisplay this record using textbox control.Note:Don’tsend me the whole application. You just send me the codedisplaying how you connect with Microsoft access database and afterthat you read employee records from employee table. Employee id, name, address and age anddisplay this record using textbox control.
Note:Don’tsend me the whole application. You just send me the codedisplaying how you connect with Microsoft access database and afterthat you read employee records from employee table.
Explanation / Answer
Here is the code to connect to the MS Access databse and bindingthe data to the datagrid.
private void Page_Load(object sender, System.EventArgs e)
{
OleDbConnection conn;
OleDbCommand comm;
OleDbDataReader dr;
conn = new OleDbConnection("Provider = Microsoft.Jet.OLEDB.4.0;Data Source = C:\database.mdb");
comm = new OleDbCommand("Select * from Table1",conn);
conn.Open();
dr = comm.ExecuteReader();
DataGrid1.DataSource = dr;
DataGrid1.DataBind();
conn.Close();
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.