You say you have added records to the table and the combobox has this as a datasource.
You have to be aware that there is a data structure called a datatable and there is a database table. These are associated with each other often but are distinctly different. The datatable is a local data type (just like a integer or string) which is populated normally as a result of a action resulting in retrieval of records from a database table. This creates a disconnected snapshot copy of the database table which can be used for actions such as data binding which is what you are doing when you are setting a datasource.
Apart from setting the datasource, you would need to set the datamember which is the field in the datatable you wish to use for displaying in the combobox.
That said - when you add records to the datatable - these will be reflected immediately in the combobox. But if you exit the application and start it up again these will not be there as you have not persisted them (saved) to the database table. To do this you would issue an update method call on the tableadapter which would update the database table records with those in the datatable. To initially populate the datatable (which is actually part of a dataset type) you would issue a fill method call on a table adapter which would create a datatable variable from a database table.
As these two are disconnected and you are binding to a datatable not directly with the database table. You need to ensure that if you are writing code that is updating the database table directly (as with Ado.net code) that you repopulate the local datatable afterwards to ensure that you get an updated snapshot of the database - which you would use for databinding on the combobox.
This may be achieved using a simple fill method call on a table adapter - or recalling whatever method you used to originally populate the datatable in the first place. As you arent showing any code - its difficult to see what you are doing but if your saying the database is getting updated but the combobox isnt then I would take a guess that you need to repopulate the dataset after you save the record to ensure that the combobox has the latest copy of the database table contents.
|