In the report page it shows all the record instead of one record? [Resolved]

Posted by Sudheep.grandhe under C# on 11/7/2011 | Points: 10 | Views : 869 | Status : [Member] | Replies : 1
Hi,

In the report page it shows all the record instead of one record? If the customer wants to search with the particular orderno.if he enteres the order no as like 1 it shows that particular record only.But,in my report page it shows all the records.how can i solve this problem.



private void btn_search_Click(object sender, EventArgs e)
{
MessageBox .Show ("");
SqlConnection con = new SqlConnection("data source=mars-104;initial catalog=marsweb;integrated security=true");
SqlCommand cmd = new SqlCommand("select compname,compaddress,invoiceno,orderno,convert(varchar,ondate,105),convert(varchar,invoicedate,105),amountstatus,netamount,netvat,tamount from tbl_report2", con);
con.Open();
cmd.Parameters.AddWithValue("@orderno", txt_orderno.Text);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
GridView1.DataSource = dt;
con.Close();
}
else
{
GridView1.Controls.Clear();
MessageBox.Show("sorry no data availlable");
}
}

Best,
Sudheep.



Responses

Posted by: Blessyjees on: 11/7/2011 [Member] Bronze | Points: 50

Up
0
Down

Resolved
Hi,

Update your command with below
SqlCommand cmd = new SqlCommand("select compname,compaddress,invoiceno,orderno,convert(varchar,ondate,105),convert(varchar,invoicedate,105),amountstatus,netamount,netvat,tamount from tbl_report2 where orderno=@orderno", con); 


Blessy Baby
Digitalmesh Softech pvt Ltd
https://blessybaby.wordpress.com/

Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response