BryanJ,
Thank you for your response. I'm sorry that I failed to mention that I had tried using the update method. However, the problem is that the dataset is not being updated by the controls; therefore the database is not updated when I call the update method. Everything I read tells me that the dataset should be updated by the controls, but it doesn't seem to be so.
I've tracked down the problem to the the fact that it never senses that the row is "Modified", but sees the row as "Unchanged" so it never pushes the data back to the database.
Some additional information may help (or may not). The dataAdapter uses the following SQL statement:
SELECT *
FROM Contact
WHERE ContactID = @ContactID;
where @ContactID is a parameter to the query. When someone selects a contact on another form and clicks a button labeled "Edit", the following code runs:
where ContactID is a public property of the ContactEdit form. Then, in the form's load event the following code happens:VB Code:
Private Sub btnContactEdit_Click(...) Handles btnContactEdit.Click Dim f As New ContactEdit() f.ContactID = cboContact.SelectedValue f.ShowDialog() End Sub
VB Code:
Private Sub ContactEdit_Load(...) Handles MyBase.Load SqlDataAdapter1.SelectCommand.Parameters(0).Value = Me.ContactID DsContact1.Clear() SqlDataAdapter1.Fill(DsContact1) End Sub
So, the dataset should contain only one row. The 'OK' button has the following code:
But the database is never updated. The messagebox was for testing purposes, and each time would say "Unchanged".VB Code:
Private Sub btnOK_Click(...) Handles btnOK.Click 'MessageBox.Show(DsContact1.Tables(0).Rows(0).RowState.ToString) SqlDataAdapter1.Update(DsContact1) DsContact1.AcceptChanges() DsContact1.Clear() Me.Dispose() End Sub
Does this help explain my situation? Is it because I have only one row in the dataset that this is a problem? Has anyone run into this before? This is my first attempt at datasets in VB.Net, and so far, it hasn't been encouraging.




). The dataAdapter uses the following SQL statement:
Reply With Quote