Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Updating Combo list after inserting new record

Posted on 2005-03-30
7
Medium Priority
?
242 Views
Last Modified: 2010-08-05
Hi,
I have a form that has a combo box who's list has Customers.  This is bound to a data adapter during form load.  The code is:

            daCustList.Fill(DataSet11)

I have a button that brings up a New Cutomer form that successfully adds a new Customer to the database.  No problem from a DB standpoint.

Once the new customer is added however, I need to refresh the Customer combo box list to show the newly added customer.  If I .Fill again, the list is appended to.

 I can't figure out how to do this, so help is appreciated.  I hope I'm using the DataAdapter & ComboBox correctly.

Regards,

Doug
0
Comment
Question by:dslocum
  • 4
  • 3
7 Comments
 
LVL 34

Expert Comment

by:Brian Crowe
ID: 13664974
To refresh instead of append

daCustList.MissingSchemaAction = MissingSchemAction.AddWithKey
daCustList.AcceptChangesDuringFill = True
0
 
LVL 1

Author Comment

by:dslocum
ID: 13665108
BriCrowe,

Thanks. Your suggestion still doesn't cause my original ComboList to include the new Customer in the list, at least in my situation.  Is there another step I need to do after your code ?  

Thanks,

Doug
0
 
LVL 34

Expert Comment

by:Brian Crowe
ID: 13665177
you may need to rebind your combobox to the dataadapter
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Author Comment

by:dslocum
ID: 13665583
BriCrowe,

Still having probs.  My code is:

    Private Sub btnCustNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCustNew.Click
        Dim FrmCust As New frmCustomer

        Try
            With FrmCust

                .ShowDialog()      'Add new customer to DB

                daCustList.MissingSchemaAction = System.Data.MissingSchemaAction.AddWithKey
                daCustList.AcceptChangesDuringFill = True
                cboCustName.Rebind()     'Added per your last suggestion

            End With

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

FYI, If I close the app and then reopen, the new Customer DOES show in the combo list.

BTW, I'm not sure if it matters, but I'm using a ComponentsOne Combo box.  I guess that this should work the same as a standard ComboBox.

I appreciate your help to hopeffuly resolve this!

Doug
0
 
LVL 34

Expert Comment

by:Brian Crowe
ID: 13665715
the lines...

daCustList.MissingSchemaAction = System.Data.MissingSchemaAction.AddWithKey
daCustList.AcceptChangesDuringFill = True

only need to be declared once for the dataadapter so you can put them in your form.load procedure

to rebind try this...
cboCustName.databindings.remove(cboCustname.databindings("Text"))
cbocustname.databindings.add("Text", myDataSet.myDataTable, "ColumnName")

0
 
LVL 1

Author Comment

by:dslocum
ID: 13671065
Hello again,

I added a Watch to the C1 ComboBox, and it appears that there are no databindings, so the technique above isn't working.  When I stated my problem originally, I thought that the control was bound.  Is there some other .NET technique that is being used?

The design-time C1 control properties are set to:

DataSource = DataSet11
DataMember = ARCUSFIL_SQL    'This is the table with the appropriate SQL Select to fill the combo's list
DisplayMember = CustName
ValueMember = Cus_No

I don't necessarily expect that you know this C1 combo control, but can you recognize the technique that is used and continue to help with my goal?

Thanks for your time and patience.

Doug
0
 
LVL 34

Accepted Solution

by:
Brian Crowe earned 1000 total points
ID: 13671262
everything looks the same as the standard combobox except for the DataMember property.  A standard  Combobox would look more like...

DataSource = DataSet11.tables("ARCUSFIL_SQL")
DisplayMember = "CustName"
ValueMember = "Cus_No"
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question