Hi,
I've been working on getting a GUI connected to a database so I can input data into the database. However when getting to the 'making a save button' I get this problem on line 14:
Private da As New SqlDataAdapter("Select Name, Number, Email From Contacts", cs)
Private ds As New DataSet
Private cmb As New SqlCommandBuilder(da)
Private Sub Main2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
da.Fill(ds, "Contacts")
dg.DataSource = ds.Tables("Contacts")
End Sub
Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
da.UpdateCommand = cmb.GetUpdateCommand
da.Update(ds.Tables("Contacts"))
End Sub
The line of code that says da.UpdateCommand = cmb.GetUpdateCommand produces an error that says:
InvalidOperationException was unhandled
Dynamic SQL generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information.
I'm not 100% sure what that means but I have tried looking but nothing I've found applies to the Dynamic SQL.
Any help would be appreciated!
Thank you!