I completed the VB version test program.
It has the same issue.
In order for the DataSet Wizard to build an Update command the dataset must have a Key field.
In my first attempt I built the db with two nvarchar fields named name and description as you have. I then used the DataSet Wizard to build the DataSet.
The New rowbutton procedureworked fine. The
testTableAdapter.Update(r) statement made use of the TableAdapter Insert Command. The Insert command needs no key to locate an existing record to operate upon.
However, the Update button procedure failed at the
testTableAdapter.Update(r) statement because there was no Update Command in the TableAdapter.
I then updated the db by adding a third field called ID as integer and made it the primary key.
I added the ID field to the DataSet and configured it as an AutoIncrement field. I ran back through the DataSet Wizard so it would build the Delete and Update commands now that there was a primary key.
This now shows the issue I've been dealing with.
I don't have an archive utility (WinZip) to create an archive of the finished program to post as you did.
Below is the VB code and the SQL that was generated in the Table Adapter.
Public Class Form1
Dim r As DataRow
'The DataSet configuration Wizard automatically generates
' a BindingNavigator ToolStrip for the associated table.
'I deleted the tool strip from the Designer.
'I left the generated code for reference and commented it out.
'--------------
'Private Sub TestBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
' Me.Validate()
' Me.TestBindingSource.EndEdit()
' Me.TableAdapterManager.UpdateAll(Me.TestDatabase1DataSet)
'End Sub
'--------------
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'TestDatabase1DataSet.test' table. You can move, or remove it, as needed.
Me.TestTableAdapter.Fill(Me.TestDatabase1DataSet.test)
End Sub
Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNew.Click
r = TestDatabase1DataSet.test.NewRow
r("name") = "???"
r("description") = String.Format("Person {0}", TestDatabase1DataSet.test.Rows.Count)
TestDatabase1DataSet.test.Rows.Add(r)
TestTableAdapter.Update(r)
End Sub
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
r = TestTableAdapter.GetData(TestDataGridView.CurrentRow.Index)
r("name") &= "+"
TestTableAdapter.Update(r)
End Sub
End Class<br/><br/><br/>
TableAdapter UpdateCommand CommandText
UPDATE test
SET name = @p1, description = @p2, ID = @p3
WHERE (ID = @p4)
Any additional thoughts?
Eric