retrieving data in a list box control

srivalli

Well-known member
Joined
May 4, 2005
Messages
189
Programming Experience
Beginner
In my form i have one field bankname

now i am adding some banks (say 5) to the backend.

it is being updated.

i kept one button which shows the names of all the banks.(in a listbox cntrl)

after data is displayed in the listbox ,i added one more bank.

data is updated in the database.

but while clicking the button,in listbox instead of showing 6 banks the data is

displayed twice that is in listbox i am getting 11 banks.

so i want to refresh the details every time when i click the button.

hope my query is clear
thank u
 
Hi,

First clear the lisbox cotrol and then requery the database. If you dont clear, the items will be added to the existing items.

listboxname.items.clear()

Hope this works out.
 
here's another perspective on the items listed in the listbox

if the items in the listbox come straight from the database (ie it's bound to a dataset) then when you add a bank to the list (add it to the dataset then update the DB from the dataset)

then all you need to do is refresh the dataset by clearing it:
dsDataSet.Clear()
daDataAdapter.Fill(dsDataSet)

and that will refresh the listbox as well (since it's bound to the dataset that gets cleared then refilled)

hope that helps, if you would like more info on using bound controls to datasets feel free to ask myself, kulrom, jmcilhinney, paszt
 
i got it thksss

i tried using ds.clear method
and igot it.
thank u


JuggaloBrotha said:
here's another perspective on the items listed in the listbox

if the items in the listbox come straight from the database (ie it's bound to a dataset) then when you add a bank to the list (add it to the dataset then update the DB from the dataset)

then all you need to do is refresh the dataset by clearing it:
dsDataSet.Clear()
daDataAdapter.Fill(dsDataSet)

and that will refresh the listbox as well (since it's bound to the dataset that gets cleared then refilled)

hope that helps, if you would like more info on using bound controls to datasets feel free to ask myself, kulrom, jmcilhinney, paszt
 
Back
Top