Re: C# - Listbox - additems by Paul
Paul
Tue Sep 09 02:10:54 CDT 2003
hello mark,
Iam sure that the names of the fields are lowercase, so thats not the
problem.
I think the problem is that the datasource can not handle a variable of the
type "SqlCeDataReader"
But iam not sure.
Did you successfull used the DisplayMember and ValueMember (including using
the SqlCeDataReader datatype) before?
Greetings
Paul
"Mark Reddick" <mark_reddick@NOSPAMlpsg.com> wrote in message
news:Ocrz8qkdDHA.1944@TK2MSFTNGP12.phx.gbl...
> I'm not sure if this is your problem, but I discovered that these two
> properties (DisplayMember and ValueMember) are case sensitive. So, perhaps
> you need to change it to "FirstName" instead of "firstname" or whatever
the
> column name case is in your table.
>
> HTH,
> Mark
>
> "Paul Govers" <pocketpc2002@paulgovers.com> wrote in message
> news:Hn57b.3003$Of7.899105@amsnews02.chello.com...
> > Hello Programmers,
> >
> > Iam trying to fill a listbox with a display value and a ID.
> > I want to put database table in the listbox and de primarykey must be
put
> in
> > the listbox as well.
> >
> > i do something wrong but i don't know what??
> >
> > my code:
> > string SQL;
> > SQL = "SELECT * FROM people";
> > cn = new SqlCeConnection();
> > cn.ConnectionString = LocalConnection;
> > cn.Open();
> > SqlCeCommand cmd = new SqlCeCommand(SQL,cn);
> > SqlCeDataReader dtr = cmd.ExecuteReader();
> > listBox1.DataSource = adapter ;
> > listBox1.DisplayMember = "firstname";
> > listBox1.ValueMember = "people_id";
> >
> > The line "listBox1.DisplayMember = "firstname";" gives a error when i
try
> to
> > run the program, but compile works juis fine.
> >
> > Can someone help me??
> >
> > Greetings
> >
> >
>
>