Data Adapter and Listboxes - general questions

G

Guest

Hello
I'm new to VB.net and have a question about using data adapters
I have 3 text boxes and a list box on my form. The text boxes are search fields that query a SQL database and return a list that populates the list box. The user would enter text into any 1 of the text boxes, or none at all, then press a button. If no text is entered, the listbox is populated with all items in table (this I can do no problem :), otherwise if textbox A has data, the listbox returns the record associated with that item, the other 2 textboxes would return 0 to a few records if used
Now my problem..
I can bind my listbox to a dataset using the properties, but how do I bind it with potentially 4 datasets?
Or am I doing this wrong from the start??
TIA
amber
 
B

Bernie Yaeger

Hi Amber,

Instead of binding it, when the button is clicked, simply .clear it and then
loop through the dataset/datatables that are appropriate and populate it
with listbox.items.add etc.

HTH,

Bernie Yaeger

amber said:
Hello,
I'm new to VB.net and have a question about using data adapters.
I have 3 text boxes and a list box on my form. The text boxes are search
fields that query a SQL database and return a list that populates the list
box. The user would enter text into any 1 of the text boxes, or none at all,
then press a button. If no text is entered, the listbox is populated with
all items in table (this I can do no problem :), otherwise if textbox A has
data, the listbox returns the record associated with that item, the other 2
textboxes would return 0 to a few records if used.
Now my problem...
I can bind my listbox to a dataset using the properties, but how do I bind
it with potentially 4 datasets??
 
C

Cor

Hi Amber,

I asume you have a button event

\\\Quickly typed as kind of psueduo
listbox1.datasource = nothing
if textbox1.text <> "" then
listbox1.datasource = myfirsttable
listbox1.displaymember= ....
else
if textbox2 <> "" then
listbox1.datassource = mysecondtable
etc
else
listbox1.datasource = myfourthtable.
etc
.....
end if
end if
////
I hope this works?

Cor

Hello,
I'm new to VB.net and have a question about using data adapters.
I have 3 text boxes and a list box on my form. The text boxes are search
fields that query a SQL database and return a list that populates the list
box. The user would enter text into any 1 of the text boxes, or none at all,
then press a button. If no text is entered, the listbox is populated with
all items in table (this I can do no problem :), otherwise if textbox A has
data, the listbox returns the record associated with that item, the other 2
textboxes would return 0 to a few records if used.
Now my problem...
I can bind my listbox to a dataset using the properties, but how do I bind
it with potentially 4 datasets??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top