A ComboBox is KILLING ME!!! [RESOLVED]
I'm trying to populate my combobox from a dataset using the following code that I picked up from the forums :) thnx
VB Code:
Private Sub PopCBOFromDB(ByRef cbo As ComboBox)
Dim Conn As New OleDb.OleDbConnection(ConnectionString)
Dim Cmd As OleDb.OleDbCommand = Conn.CreateCommand
Cmd.CommandText = SQLString
Conn.Open()
Dim DA As New OleDb.OleDbDataAdapter
DA.SelectCommand = Cmd
DA.Fill(DS)
cbo.DataSource = DS.Tables("Table")
cbo.DisplayMember = Field
End Sub
Private Sub cboBON_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboBON.DropDown
PopCBOFromDB(cboBON)
End Sub
The problem is that when I change anything to the actual database (like delete a record in the table I'm pulling my DisplayMember field from) it still shows that same record in the combobox... I'm having trouble going the other way too. e.g. when I add a record to the table it doesn't show the new record.
However, if I close the form and open it again, it will show any changes that were made while it was open the last time. ????? I don't know ?????
Can anyone of you friendly genious types help me?
Thanks,
Squirrelly1 :D