Hi All,
I have had some reall problems with this. I have a form with a datagridview, now I can add new records and the dataset will update fine, but it wont update when I want to delete a record.
Please see below my code.
Imports System.Data.SqlClient
Public Class Form2
Dim da As SqlDataAdapter
Dim conn As SqlConnection
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conn = New SqlConnection("Data Source=JOHN-ELLIS-PC;Initial Catalog=mtrmanager;Integrated Security=True")
conn.Open()
Me.UsersTableAdapter.Fill(Me.MtrmanagerDataSet.Users)
End Sub
Private Sub UsersBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Try
Dim myBuilder As SqlCommandBuilder = New SqlCommandBuilder(da)
da.SelectCommand = myBuilder.GetDeleteCommand
da.UpdateCommand = myBuilder.GetUpdateCommand
da.Update(Me.MtrmanagerDataSet)
Me.Validate()
Me.UsersBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.MtrmanagerDataSet)
Catch ex As Exception
MsgBox("Updated Failed" & ex.Message)
End Try
End Sub
Private Sub Form2_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
conn.Close()
End Sub
End Class
I dont actually get any design or runtime errors, the dataset just will not update. I have been into the configuration screen for the dataset and made sure that all the correct check boxes are selected.
Not sure what else to do? has anyone got any idea's.
Thanks
John