Hi, I am getting a tad confused with the methods used to populate and repopulate of a combobox.
Here is the story:
I have a combobox on a form that is setup as follows:
datasource = MB2007DataSetBindingSource
displaymember = tran_description
valuemember = tran_id
MB2007DataSetBindingSource is setup as follows:
datasource = MB2007DataSet
datamember = transaction_descriptions
And there is also a data adapter named daTransactiondescriptions
When the form loads this line is executed:
Now this works a treat and as I would expect. However the problem arises when I write data to the table.
I guess I am missing something here, but this is my code:
this code successfully adds the new item to the combo box but I seem to be failing in getting it to commit the change to the database as when I open up the table after closing the apoplication the new entry has not been written?
Any tips please?
Thnx
Here is the story:
I have a combobox on a form that is setup as follows:
datasource = MB2007DataSetBindingSource
displaymember = tran_description
valuemember = tran_id
MB2007DataSetBindingSource is setup as follows:
datasource = MB2007DataSet
datamember = transaction_descriptions
And there is also a data adapter named daTransactiondescriptions
When the form loads this line is executed:
Code:
Me.daTransactiondescriptions.Fill(Me.MB2007DataSet.transaction_descriptions)
Now this works a treat and as I would expect. However the problem arises when I write data to the table.
I guess I am missing something here, but this is my code:
Code:
Try
' create a row from the dataset data table
Dim drDataRow As DataRow = Me.MB2007DataSet.transaction_descriptions.NewRow()
' set the transaction description using the users input
drDataRow("tran_description") = Me.txtNewTransactionDescription.Text
' add the row to the table
Me.MB2007DataSet.transaction_descriptions.Rows.Add(drDataRow)
' commit changes to database
Me.daTransactiondescriptions.Update(Me.MB2007DataSet.transaction_descriptions)
' clear the user input field and set focus
Me.txtNewTransactionDescription.Clear()
Me.txtNewTransactionDescription.Select()
Catch objError As Exception
' tell user no connection made
MessageBox.Show("Failed to save transaction description to the database" & vbCrLf & vbCrLf & objError.Message, "Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
this code successfully adds the new item to the combo box but I seem to be failing in getting it to commit the change to the database as when I open up the table after closing the apoplication the new entry has not been written?
Any tips please?
Thnx