syntia.wijaya
Member
Hi, I am a one and half week old VB.NET newbie. I have a simple yet frustratring problem that costs me 3 days and still not yet solved
I have 2 tables, Workpack and WP_Activity
Workpack
--------
WP_ID (PK)
Description
Plan_Start
Plan_Finish
WP_Activity
-----------
Part_ID (PK)
Part
Act_Desc
Quantity
WP_ID (FK)
I am trying to make master details in one form with 2 DataGridView. The master records are taken from workpack table and the details are taken from WP_Activity table. When I select the master's row, the details DataGridView will automatically changed the records where WP_Activity.WP_ID = Workpack.WP_ID. That works well.
Now, I want to update table WP_activity in database using click button event. This is the code I put in Sub saveButton_click:
Private Sub saveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles saveButton.Click
Dim tableName As String = "WP_Activity"
Dim cb As SqlCommandBuilder = New SqlCommandBuilder(detailsDataAdapter)
cb.DataAdapter.Update(dataSet, tableName)
End Sub
When I click the save button, I got
InvalidOperationException:
Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.
I have tried thousands of code examples (a lil hyperbolic here ), but each generate different error or exception.
Oya, I use VS 2005 and SQL Server 2005.
Thank you in advance.
Regards,
Syntia Wijaya
I have 2 tables, Workpack and WP_Activity
Workpack
--------
WP_ID (PK)
Description
Plan_Start
Plan_Finish
WP_Activity
-----------
Part_ID (PK)
Part
Act_Desc
Quantity
WP_ID (FK)
I am trying to make master details in one form with 2 DataGridView. The master records are taken from workpack table and the details are taken from WP_Activity table. When I select the master's row, the details DataGridView will automatically changed the records where WP_Activity.WP_ID = Workpack.WP_ID. That works well.
Now, I want to update table WP_activity in database using click button event. This is the code I put in Sub saveButton_click:
Private Sub saveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles saveButton.Click
Dim tableName As String = "WP_Activity"
Dim cb As SqlCommandBuilder = New SqlCommandBuilder(detailsDataAdapter)
cb.DataAdapter.Update(dataSet, tableName)
End Sub
When I click the save button, I got
InvalidOperationException:
Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.
I have tried thousands of code examples (a lil hyperbolic here ), but each generate different error or exception.
Oya, I use VS 2005 and SQL Server 2005.
Thank you in advance.
Regards,
Syntia Wijaya
Last edited: