Results 1 to 8 of 8

Thread: A ComboBox is KILLING ME!!! [RESOLVED]

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2001
    Location
    USA
    Posts
    1,026

    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:
    1. Private Sub PopCBOFromDB(ByRef cbo As ComboBox)
    2.         Dim Conn As New OleDb.OleDbConnection(ConnectionString)
    3.         Dim Cmd As OleDb.OleDbCommand = Conn.CreateCommand
    4.         Cmd.CommandText = SQLString
    5.         Conn.Open()
    6.         Dim DA As New OleDb.OleDbDataAdapter
    7.         DA.SelectCommand = Cmd
    8.         DA.Fill(DS)
    9.         cbo.DataSource = DS.Tables("Table")
    10.         cbo.DisplayMember = Field
    11.     End Sub
    12.  
    13.     Private Sub cboBON_DropDown(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboBON.DropDown
    14.         PopCBOFromDB(cboBON)
    15.     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
    Last edited by squirrelly1; Nov 20th, 2004 at 11:50 PM.
    Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width