habib ullah

habib ullah

  • 1.9k
  • 229
  • 11.1k

i have a searching in database if record not found then mess

May 16 2017 2:33 AM
we make a searching in database if the record is not found then show the message "sorry record is not found" how i can do it help me solve problem my code is that
 
if (ds.Tables["tbl_transaction"].Rows.Count > 0)
{
label1.Text = "sorry record not found";
}
else
{
ds = cls.loaddataset("select * from tbl_expdtl where e_date = '" + dateTimePicker2.Text + "'", "tbl_expdtl");
object query = cls.getspecefisrecord("select sum(amount) from tbl_expdtl where e_date='" + dateTimePicker2.Text + "'");
lbl_show.Text = Convert.ToString(query);
dataGridView3.Rows.Clear();
for (int b = 0; b <= ds.Tables["tbl_expdtl"].Rows.Count - 1; b++)
{
dataGridView3.Rows.Add();
dataGridView3.Rows[b].Cells[0].Value = ds.Tables["tbl_expdtl"].Rows[b]["p_id"];
dataGridView3.Rows[b].Cells[1].Value = ds.Tables["tbl_expdtl"].Rows[b]["expence"];
dataGridView3.Rows[b].Cells[2].Value = ds.Tables["tbl_expdtl"].Rows[b]["amount"];
dataGridView3.Rows[b].Cells[3].Value = ds.Tables["tbl_expdtl"].Rows[b]["remarks"];
dataGridView3.Rows[b].Cells[4].Value = ds.Tables["tbl_expdtl"].Rows[b]["e_date"];
this.dataGridView3.RowsDefaultCellStyle.BackColor = Color.Bisque;
this.dataGridView3.AlternatingRowsDefaultCellStyle.BackColor = Color.Beige;
}
 }
 

Answers (4)