10
Reply

How to display a new row without removing the previous rows (c# datagridview)?

wsdfg

wsdfg

Feb 22 2010 4:15 PM
4.8k
ok so I made a datagridview. when I enter the primary key it will display the data. what I want to do next is make it so that when I enter another primary key it will display the next data and the previous data. heres what I got

public void loadDataGrid(string sqlQueryString)
{
OleDbCommand SQLQuery = new OleDbCommand();
DataTable data = null;
dataGridView1.DataSource = null;
SQLQuery.Connection = null;
OleDbDataAdapter dataAdapter = null;

dataGridView1.Columns.Clear();
SQLQuery.CommandText = sqlQueryString;
SQLQuery.Connection = database;
data = new DataTable();
dataAdapter = new OleDbDataAdapter(SQLQuery);
dataAdapter.Fill(data);
dataGridView1.DataSource = data;
dataGridView1.AllowUserToAddRows = false;
dataGridView1.ReadOnly = true;
dataGridView1.Columns[0].Visible = false;
}

currently it just displays the recent data only, it doesnt show the previous ones.. is there a command to do this?

Answers (10)