public void populateGridView() { studentMarksTableAdapter = new OleDbDataAdapter(); studentsDataSet = new DataSet(); studentMarksTableAdapter.SelectCommand = dbCmd; studentMarksTableAdapter.Fill(studentsDataSet, "StudentMarks"); gridViewAll.DataSource = studentsDataSet.Tables[0]; } private void Form1_Load(object sender, EventArgs e) { // Connect to Database: string sConnection = "Provider = Microsoft.Ace.OLEDB.12.0;Data Source=Students.accdb"; dbConn = new OleDbConnection(sConnection); dbConn.Open(); // Connect the Command to the Connection: sql = "SELECT * FROM StudentMarks "; dbCmd = new OleDbCommand(); dbCmd.CommandText = sql; dbCmd.Connection = dbConn; populateGridView(); dbConn.Close(); } private void cboFilter_SelectedIndexChanged(object sender, EventArgs e) { if (cboFilter.Text == "Student Number") { sql += "Order By StudentNumber ASC"; populateGridView(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)