I am writing my self a simple little address book application and I seem to be having some trouble with updating the dataset.
I have written the code and I cant see for any reason why it shouldnt work, but during run time, when I delete an entry and try to save the changes I get the following error.
Update failed dynamic sql generation for the delete command is not supported against a select command that does not return key column information.
I have never come accross this error before. Please see my code below.
Imports System.Data.SqlClient Public Class AddAddress Dim conn As SqlConnection Dim daAddressBook As SqlDataAdapter Dim dsAddressBook As DataSet Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click Me.Close() End Sub Private Sub AddAddress_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try conn = New SqlConnection("Data Source=JOHN-ELLIS-PC;Initial Catalog=AddressBookdb;Integrated Security=True") dsAddressBook = New DataSet daAddressBook = New SqlDataAdapter("SELECT Name,HomeTellNumber,MobileTellNumber,BirthDay,Email,Address FROM Details", conn) Dim cmdBldr As SqlCommandBuilder = New SqlCommandBuilder(daAddressBook) daAddressBook.Fill(dsAddressBook, "AddressBook") DataGridView1.DataSource = dsAddressBook.Tables("AddressBook") Catch ex As Exception MsgBox(ex.Message) End Try End Sub Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click Try daAddressBook.Update(dsAddressBook, "AddressBook") MessageBox.Show("Address Book Updated") Catch ex As Exception MessageBox.Show("Update Failed" & ex.Message) End Try End Sub End Class
Any help on what has gone wrong would be much apreciated.