dslocum
asked on
Updating Combo list after inserting new record
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
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
ASKER
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
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
you may need to rebind your combobox to the dataadapter
ASKER
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.MissingSchemaAc tion = System.Data.MissingSchemaA ction.AddW ithKey
daCustList.AcceptChangesDu ringFill = 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
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.MissingSchemaAc
daCustList.AcceptChangesDu
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
the lines...
daCustList.MissingSchemaAc tion = System.Data.MissingSchemaA ction.AddW ithKey
daCustList.AcceptChangesDu ringFill = 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.r emove(cboC ustname.da tabindings ("Text"))
cbocustname.databindings.a dd("Text", myDataSet.myDataTable, "ColumnName")
daCustList.MissingSchemaAc
daCustList.AcceptChangesDu
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.r
cbocustname.databindings.a
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
daCustList.MissingSchemaAc
daCustList.AcceptChangesDu