Dear All, I have a combobox, two dtp(will find in one col) and a dgv. I want the result, when I shall press btn then dgv will appear that 10th col ("CibtcaNo") of dgv are filled.
private void btnAdjusted_Click(object sender, EventArgs e)
{
if ((comboBoxEnterSuspenseAccount.Text.ToString() != "") && (dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells["CibtcaNo"].Value.ToString() != ""))
{
con = new OleDbConnection(conString);
var query = "SELECT * FROM LalData " +
" WHERE " +
"SuspenseAccount = @suspenceAccount1 " +
"AND " +
"(PaymentDate BETWEEN @firstDate AND @lastDate)";
con.Open();
OleDbCommand cmd = new OleDbCommand(query, con);
cmd.Parameters.AddWithValue("@suspenceAccount1 ", DbType.String).Value = comboBoxEnterSuspenseAccount.Text.ToString();
cmd.Parameters.AddWithValue("@fromDate ", DbType.Date).Value =
dtpFirstDate.Value.ToShortDateString();
cmd.Parameters.AddWithValue("@toDate ", DbType.Date).Value =
dtpLastDate.Value.ToShortDateString();
adapter = new OleDbDataAdapter(cmd);
adapter.Fill(dt);
dataGridView1.DataSource = dt;
dataGridView1.CurrentCell = dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[0];
con.Close();
}
}