Hi,
it's working sir.But,in combobox if i selected one value it has to display the remaining textboxes.but,it will not display.what is the error.please do the needful.
public partial class UpdateCustomerInvoice : Form
{
public UpdateCustomerInvoice()
{
InitializeComponent();
}
string str;
SqlConnection con;
SqlDataAdapter da;
DataSet ds;
DataSet ds1;
private void UpdateCustomerInvoice_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("data source=mars-104;initial catalog=marsweb;integrated security=true");
SqlCommand cmd = new SqlCommand(" select t2.compname,t2.compaddress,t2.invoiceno,t2.orderno,t2.ondate,t2.invoicedate,t2.amountstatus,t2.netamount,t2.netvat,
t2.tamount,t1.particulars,t1.quantity,t1.perprice,t1.amount
from tbl_report2 t2 left join tbl_report1 t1 on t1.invoiceno=t2.invoiceno", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
foreach (DataRow row in ds.Tables[0].Rows)
{
cmb_customername.Items.Add(row.ItemArray[0].ToString());
}
con.Close();
}
private void cmb_customername_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("data source=mars-104;initial catalog=marsweb;integrated security=true");
con.Open();
SqlCommand cmd = new SqlCommand(" select t2.compname,t2.compaddress,t2.invoiceno,t2.orderno,t2.ondate,t2.invoicedate,t2.amountstatus,t2.netamount,t2.netvat,
t2.tamount,t1.particulars,t1.quantity,t1.perprice,t1.amount
from tbl_report2 t2 left join tbl_report1 t1 on t1.invoiceno=t2.invoiceno", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds );
DataRow trow;
ds.Tables[0].PrimaryKey = (new DataColumn[]{
ds .Tables [0].Columns [0]});
trow = ds.Tables[0].Rows.Find(cmb_customername.Text);
txt_customeraddress.Text = trow["custaddress"].ToString();
}
}
}
Best,
Sudheep.
Sudheep.grandhe, if this helps please login to Mark As Answer. | Alert Moderator