I have a listbox that gets populated in code by a reader result set
from a stored proc on SQL Server 2005. In building this I created a
set of test rows in the DB and the code runs fine and populates the
box. Next I added functionality to add data. This adds data to the DB
and then forces the listbox to refresh by clearing it's contents and
then re-running the populate code.
However, when I add an item and do the refresh, the listbox does not
get the new entry. I debugged this and the DB gets updated (in fact I
stopped just after the DB update code and ran the proc that gets the
listbox data on the SQL server manager and it showed that the data was
indeed there.
But once the list box populate code runs, the new entry is missing. If
I terminate the application and run it again, the new data shows up.
Is something getting cached with the SQL reader object? It falls out
of scope in the proc that populates the list box so I assumed that it
was gone and got re-created on the next call. Both the reader object
and the connection object have their .close methods called before the
populate proc ends.
Can someone shed some light?
Thanks!