Re: Select Statement by Chris
Chris
Tue May 31 08:15:50 CDT 2005
You can't do what you're trying to do with the DataReader. It only contains
the current record that it has read from the record set.
anyway, rdr( "arr(lstbox1.selectedindex )") is trying to return the field
called "arr(lstbox1.selectedindex)" from the current record in the reader
which should either return an error, or null, not sure which...
You would be better off creating a little object to display in your listbox
that has 2 properties (Name and Id) and set the DisplayMember property of
the listbox to the 'Name' property of your object.
Or you could use your current technique, but write something like:
str = "select * from contacts where id = '" & arr(listbox1.SelectedIndex) &
"'";
"A.J" <ajay.bisht@gmail.com> wrote in message
news:1117523234.482524.289310@g44g2000cwa.googlegroups.com...
Application: When a user selects a name in the listbox complete
information(phone-no,E-mail,etc..) regarding the person should be
displayed.
Problem: I have populated the list-box with names using datareader.The
database comprise of id with respect to each name.Now since the id's
are unique thats why while populating the listbox i am storing the id's
in an array.
dim arr(10) as integer
ex. arr(i) = rdr("id").
Now when the user selects a name the query i am writing is
str = "select * from contacts where id = '" &
rdr( "arr(lstbox1.selectedindex )") & "'"
Now i am getting error in the where clause.
Please Help..