HI,
with out entering any details into the textbos.if i made click on search button it displays the data.how can i rectify this error.please do the needful.here is my code.
namespace marsweb.imageimpacts
{
public partial class OrderSearch : Form
{
int id1=1;
public OrderSearch()
{
InitializeComponent();
}
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)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=marsweb;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");
}
}
private void txt_orderno_TextChanged(object sender, EventArgs e)
{
GridView1.Controls.Clear();
}
private void OrderSearch_Load(object sender, EventArgs e)
{
//GridView1.Controls.Clear();
//txt_orderno.Focus();
}
}
}
Best,
Sudheep.
Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator