- private void Bsearch_Click(object sender, EventArgs e)
- {
- try
- {
- connection.Open();
- OleDbCommand command = new OleDbCommand();
- command.Connection = connection;
- string query = "select* from Students WHERE Firstname LIKE '" + tbsearchid.Text + "'";
- command.CommandText = query;
- OleDbDataReader reader = command.ExecuteReader();
- while (reader.Read())
- {
- tbFname.Text = reader["Firstname"].ToString();
- tbLname.Text = reader["Lastname"].ToString();
- /*this part*/ tbmulti.Text = reader[(Course1: + "Course1") (Course2 + "Course2")].ToString(); // my access db has 10 courses colums course1 -course10
- /*this part*/ tbavg.Text = reader[ provide the avg of the courses]
- /*this part*/ tbmax.Text = reader[provides the max of the courses]
- }
- connection.Close();
- }
- catch (Exception ex)
- {
- MessageBox.Show("Error " + ex);
- }
How to display data from Access database? C#



Rajanikant HawaldarRank #110 · 20.2K reputationPosted Aug 5, 2019, 7:59 PM EDT
Amit KumarRank #459 · 5.4K reputationPosted Aug 5, 2019, 6:55 PM EDT
Sonu GuptaRank #1,261 · 1.4K reputationPosted Aug 6, 2019, 8:44 PM EDT