This is in visual studio 2015, C# and MS Access database. I want to select from datagrid view not from database. How? Please code or example.
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
con = new OleDbConnection(conString);
string sql = "SELECT * FROM LalData WHERE SuspenceAccount like '" + comboBox1.Text + "%'";
con.Open();
adapter = new OleDbDataAdapter(sql, con);
dt = new DataTable();
adapter.Fill(dt);
dataGridView1.DataSource = dt;
dataGridView1.CurrentCell = dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[0];
btnSubmit.Enabled = false;
con.Close();
}

Ramesh PalanivelRank #372 · 6.8K reputationPosted May 5, 2017, 1:12 AM EDT
Amit GuptaRank #190 · 12.8K reputationPosted May 5, 2017, 1:13 AM EDT
Rafnas T PRank #280 · 8.8K reputationPosted May 5, 2017, 3:43 AM EDT