Hello, my code is below:
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'sampleDataSet.contact_Query' table. You can move, or remove it, as needed.
//this.contact_QueryTableAdapter.Fill(this.sampleDataSet.contact_Query);
OleDbConnection aConnection = new OleDbConnection(dbconnection);
OleDbCommand aCommand = new OleDbCommand("select id, name, mobile_num, date_created from contact order by id", aConnection);
try
{
aConnection.Open();
//OleDbDataReader aReader = aCommand.ExecuteReader();
OleDbDataAdapter oAdapter = new OleDbDataAdapter();
oAdapter.SelectCommand = aCommand;
DataSet ds = new DataSet();
//Get the data for the selected table and populate the Grid
oAdapter.Fill(ds);
//Persist the Table Data to enable paging.
dsTemp = ds;
//If the dataset contains rows
if (ds.Tables[0].Rows.Count > 0)
{
//Send to our Fill Grid method
fillDataGrid_dtgBrowse(ds);
dataGridView1.Columns[0].Visible = false ;
dataGridView1.Columns[1].HeaderText = "Name";
dataGridView1.Columns[2].HeaderText = "Mobile Number";
dataGridView1.Columns[2].Width = 110;
dataGridView1.Columns[3].HeaderText = "Date Added";
DataGridViewCheckBoxColumn col = new DataGridViewCheckBoxColumn();
col.FalseValue = "0";
col.TrueValue = "1";
col.Width = 30;
dataGridView1.Columns.Insert(0, col);
}
else
{
bindingSource1.DataSource = null;
bindingSource1.Clear();
dataGridView1.DataSource = bindingSource1;
}
aConnection.Close();
}
catch (Exception exp)
{
MessageBox.Show("Error: {0}", exp.Message);
}
finally
{
}
}
and it filled up the datagridview. however, when I change the sql statement to:
OleDbCommand aCommand = new OleDbCommand("select id, name, mobile_num, date_created from contact order by id DESC", aConnection);
with a DESC behind, no record display in the datagridview.
Please kindly advice. Thanks in advance!
Cheers,
Mark