Ekona Pikin

Ekona Pikin

  • NA
  • 38
  • 13.2k

How to Refresh a dataGridView in C#

Mar 21 2015 11:42 PM
I have a  datagridview in windows form. I have added a timer as well. So in the timer_tick method, I had called a method to retrieve data to the gridview from my Access databse. But now I want to refresh the datagrid view as soon as it updates the table. I have added following code, but it doesn't work. What am I doing wrong?
 
protected void FillDataGridView() { // create an open the connection     
OleDbConnection conn = new OleDbConnection(conString);
 OleDbCommand command = new OleDbCommand();
command
= conn.CreateCommand();
// create the DataSet DataSet ds = new DataSet();
// run the query command.CommandText = "SELECT * FROM TexasClub";
OleDbDataAdapter adapter = new OleDbDataAdapter();
 adapter
= new OleDbDataAdapter(command);
adapter
.Fill(ds); } private void timer1_Tick(object sender, EventArgs e)
 {
 //Call the FillGridview method FillDataGridView();
 }

Answers (4)