Thank you for the replies!
As it turns out, I don't think it is my combo causing the problem. I think
it is my dataset.
Here is the scenario. I have a form with a combo on it. Beside the combo is
a button that displays a dialog that will add a record to the table that my
combo is bound to. On closing the dialog I Insert the new record into the
database using an Insert statement and .ExecuteNonQuery().
When the dialog is close, I refresh my dataset and rebind the combo. When I
refresh the dataset, the database table contents is appended to the end of
the dataset table. The second set of data does contain the new record.
Here is an example:
myCnn.Open()
cmd = new SQLCommand("Select * from tblUOM Order By fldName")
adapt = new SQLDataAdapter(cmd, myCnn)
adapt.fill(myDataSet, "tblUOM")
myCnn.Close()
MsgBox(myDataSet.Tables("tblUOM").Rows.Count.toStr ing())
The actual code I was working on is at home, so that is off the top of my
head. It is pretty straight forward, nothing out of the ordinary. When it
runs through the first time, My message box displays 4, but the second time
it displays 9.
The contents of my combo go from {1,2,3,4} to {1,2,3,4,1,2,3,4,5}. I have
done this same thing in ASP.Net using C#, and the dataset updates like I
would expect. This time I am using VBExpress and SQLExpress. Is that were
the bug lies or is it something I am doing?
Shouldn't the dataset just update on the second fill or do I have to clear
the table in the dataset and refill it (which does work by the way)?
Anyway, being a bit long winded and probably rambling at this point.
Thanks
Brian
"Brian" <br***********@nospam.gmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I am having a heck of a time trying to refresh data in a combobox. I have a
combo box that periodically needs to have its bound data refreshed. I can
refresh the data, but every time I refresh it the updated contents of my
data source is added to the combo and the existing list is not cleared.
I have tried calling Items.Clear() before the bind and this didn't work.
It
told me I couldn't call it when .DataSource was set, so I set it to
Nothing
and then called Items.Clear(). Still nothing.
I know that I am probably missing something blatantly obvious! Does
anybody
have any suggestions?
Thank You
Brian