4
Reply

How to Refresh a dataGridView in C#

Ekona Pikin

Ekona Pikin

Mar 21 2015 11:42 PM
811
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();
 }

Upload Source Code  Select only zip and rar file.
Answers (4)