updating a combobox after database has been updated

jamie123

Well-known member
Joined
May 30, 2008
Messages
82
Programming Experience
Beginner
Hey,
To start out, i'm programming in vb.net using vs2008, using sqlserver 2005 and have a combobox binded to a column in one table of my database.

I have a form that allows you to enter data that will go into the same column that the combobox is binded to. After the information is submitted from form to database, I want the combobox to instantly be updated with the new information. Here is what I have:

'Insert data into db
LTableAdapter.InsertMFGR(txtName.Text, txtAddress.Text, txtCity.Text, txtState.Text, txtZip.Text, txtPhone.Text, txtFax.Text)
'Refresh combobox code
Me.LTableAdapter.Fill(Me.EDataSet.Labs)
frmAddFrames.cboMFGR.Refresh()
frmAddFrames.Update()
frmAddFrames.Refresh()

Me.Close()


I've had similar problems in the past with dgv's not upgrading, and i finally learned how to upgrade them (by reloading the dataset), however, as you can see I've tried this in this case and its not working, how else can I update the combobox after info insertion?

Thanks!
 
Insert your new record directly into you datsettable, then to send it to the database call the dataadapters update method
 
VB.NET:
Dim rowNew As Datrow

rowNew = Me.EDataSet.Labs.NewRow
rowNew("Name") = txtName.Text.Trim
rowNew("Address") = txtAddress.Text.Trim
Me.EDataSet.Labs.Rows.Add(rowNew)
Me.LTableAdapter.Update(Me.EDataSet.Labs)
 
Thanks for the help, unfortunately, the code you presented does the same thing as the code I had, it'll get entered into the database, but it won't automatically refresh the combobox. to get the combobox to display updated information, i have to close and reopen the form.

What else can I do to have it refresh the info loaded?
 

Latest posts

Back
Top