for every record it shows the same values? [Resolved]

Posted by Sudheep.grandhe under C# on 12/15/2011 | Points: 10 | Views : 1206 | Status : [Member] | Replies : 2
Hi,

in my order form if i enter the particular orderno it has to show the values.for every record it shows the same values not changed.

public partial class OrderSearch : Form
{
int id1=1;
public OrderSearch()
{
InitializeComponent();
}

private void btn_search_Click(object sender, EventArgs e)
{

if (txt_orderno.Text != string.Empty)
{
//MessageBox .Show ("");
SqlConnection con = new SqlConnection("data source=mars-104;initial catalog=Sudheeptest;integrated security=true");
SqlCommand cmd = new SqlCommand("select compname,compaddress,invoiceno,orderno,convert(varchar,ondate,105)as [ondate],convert(varchar,invoicedate,105)as [invoicedate],amountstatus,netamount,netvat,tamount from tbl_report2 where orderno=@orderno", 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();
GridView1.DataSource = null;
MessageBox.Show("sorry no data availlable");
}

SqlConnection con1 = new SqlConnection("data source=mars-104;initial catalog=Sudheeptest;integrated security=true");
SqlCommand cmd1 = new SqlCommand("select particulars,orderno,quantity,perprice,amount from tbl_report1 where invoiceid=@id1", con1);
cmd1.Parameters.AddWithValue("@id1", id1);
SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
DataTable dt1 = new DataTable();
da1.Fill(dt1);
if (dt1.Rows.Count > 0)
{
GridView2.DataSource = dt1;

con.Close();
}
else
{
GridView2.DataSource = null;
MessageBox.Show("sorry no data availlable");
}
}
else
{

MessageBox.Show("Please Enter a Order Number");
}

}

Best,
Sudheep.



Responses

Posted by: Sudheep.grandhe on: 12/15/2011 [Member] Starter | Points: 25

Up
0
Down

Resolved
Hi,

the issue was resolved by vuyiswamb with the help of teamviewer.He helped me a lot .this blog is very nice.keep doing once again thanks to vuyiswamb.


Best,
Sudheep.

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

Posted by: Sudheep.grandhe on: 12/15/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

the issue was resolved by vuyiswamb.He helped me a lot .this blog is very nice.keep doing once again thanks to vuyiswamb.

Best,
Sudheep.

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

Login to post response