Shovan Saha

Shovan Saha

  • NA
  • 321
  • 92.6k

Add a condition

Jul 24 2017 3:58 PM
I want to add a condition: dgvrow.Cells["CibtcaNO"].Value.ToString() != "". How? Please help me.
  
private void btnAdjusted_Click(object sender, EventArgs e)
{
con = new OleDbConnection(conString);
if (comboBoxEnterSuspenseAccount.Text != "")  
{
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("@firstDate ", DbType.Date).Value =
dtpFirstDate.Value.ToShortDateString();
cmd.Parameters.AddWithValue("@lastDate ", 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();
}
}

Answers (3)