4
Answers

How to Refresh a dataGridView in C#

Ekona Pikin

Ekona Pikin

9y
1.5k
1
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)
Next Recommended Forum