Click here to Skip to main content
15,902,636 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
con = new SqlConnection(str);
            con.Open();
            string combined = "select code_customer,insurance_type,branch_name,name,address,insurance_cost,record_date  from customers,branches,insurance_type where branches.code_branch=customers.code_branch and insurance_type.code_type=customers.code_type";
            dset = new DataSet();
            da = new SqlDataAdapter(combined, con);
            da.Fill(dset, "customers");
            builder = new SqlCommandBuilder(da);            
            dataGridView1.DataSource = dset.Tables["customers"];
            comboBox1.DataSource = dset.Tables["customers"];
            comboBox1.DisplayMember = "insurance_type";
            comboBox2.DataSource = dset.Tables["customers"];
            comboBox2.DisplayMember = "branch_name";
            textBox1.DataBindings.Add("Text",dset.Tables["customers"], "name");
            textBox2.DataBindings.Add("Text",dset.Tables["customers"], "address");
            textBox3.DataBindings.Add("Text",dset.Tables["customers"], "insurance_cost");
            dateTimePicker1.DataBindings.Add("value", dset.Tables["customers"], "record_date");.
Posted
Updated 5-Dec-11 0:46am
v2
Comments
Dylan Morley 5-Dec-11 6:46am    
What is the error? Post the exception message
uspatel 5-Dec-11 6:48am    
and what error you face?
E.F. Nijboer 5-Dec-11 6:55am    
Connection still open? Try using 'using': http://www.w3enterprises.com/articles/using.aspx
mhassan083 5-Dec-11 7:24am    
about two binding
[no name] 5-Dec-11 20:36pm    
Would you mind sharing the exact exception?

1 solution

As far as I am aware you cannot bind a source field to more than one control at a time, therefore as you are binding all fields to the grid view you cant then bind them to another source. Check by removing the line that binds to the gridview.

You also need to set the datepicker DataSource as well.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900