it shows the following error in combobox event coding?

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

it shows the following error in combobox event coding?
Error:
it shows the following error in combobox event coding?


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[]{//error shows here as :These columns don't currently have unique values.
ds .Tables [0].Columns [0]});//error shows here as :These columns don't currently have unique values.
trow = ds.Tables[0].Rows.Find(cmb_customername.Text);
txt_customeraddress.Text = trow["custaddress"].ToString();
txt_invoiceno.Text = trow["invoiceno"].ToString();
txt_orderno.Text = trow["orderno"].ToString();
}

Best,
Sudheep.



Responses

Posted by: Hmanjarawala on: 12/9/2011 [Member] Bronze | Points: 25

Up
0
Down
Make sure that you Column[0] contains all unque and not ull value.....caz it is required in order to generate primary key

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

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

Login to post response