Hi
I am new to VS.NET and C#.
I am trying to do one of the exercises in a book "Teach
Yourself Visual Studio .NET in 21 Days" and I can't
figure out what is wrong with the following code:-
private void Load_Customers( )
{
SqlConnection cn = new
SqlConnection
(@"Server=
(local);DataBas e=Northwind;Int egrated Security=SSPI") ;
SqlDataAdapter da = new
SqlDataAdapter
("SELECT * FROM
Customers", cn);
DataSet ds = new DataSet
("Customers" );
da.Fill(ds,"Cus tomers");
// foreach (DataRow dr in ds.Tables
["Customers"].Rows)
// {
// MessageBox.Show (dr
["CustomerID "].ToString(), "Data",
//
MessageBoxButto ns.OK, MessageBoxIcon. Exclamation);
// } This proved that I could get a
string of CustomerID's
comboBox2.DataS ource = ds;
comboBox2.Value Member
= "CustomerID "; <<<<<<<< Error here! <<<<
comboBox2.Displ ayMember
= "CustomerID ";
}
I'm getting an error ...
"An unhandled exception of
type 'System.Argumen tException' occurred in
system.windows. forms.dll
Additional information: Could not bind to the new display
member."
.... on the marked line. The commented out lines were put
in to prove that I could see the data on the server and
worked OK.
Any ideas! It must be simple!
TIA
Cheers
Jeff
							
						
					I am new to VS.NET and C#.
I am trying to do one of the exercises in a book "Teach
Yourself Visual Studio .NET in 21 Days" and I can't
figure out what is wrong with the following code:-
private void Load_Customers( )
{
SqlConnection cn = new
SqlConnection
(@"Server=
(local);DataBas e=Northwind;Int egrated Security=SSPI") ;
SqlDataAdapter da = new
SqlDataAdapter
("SELECT * FROM
Customers", cn);
DataSet ds = new DataSet
("Customers" );
da.Fill(ds,"Cus tomers");
// foreach (DataRow dr in ds.Tables
["Customers"].Rows)
// {
// MessageBox.Show (dr
["CustomerID "].ToString(), "Data",
//
MessageBoxButto ns.OK, MessageBoxIcon. Exclamation);
// } This proved that I could get a
string of CustomerID's
comboBox2.DataS ource = ds;
comboBox2.Value Member
= "CustomerID "; <<<<<<<< Error here! <<<<
comboBox2.Displ ayMember
= "CustomerID ";
}
I'm getting an error ...
"An unhandled exception of
type 'System.Argumen tException' occurred in
system.windows. forms.dll
Additional information: Could not bind to the new display
member."
.... on the marked line. The commented out lines were put
in to prove that I could see the data on the server and
worked OK.
Any ideas! It must be simple!
TIA
Cheers
Jeff
Comment