Silverlight / WPF - Delete command to Data-base

Asked By David on 19-Jul-10 04:42 PM

I am still having trouble getting the data-row in a Access data-base linked to my WPF project to delete.

The delete button was made from following the Beth Massi video on Data input sheet and information comes from  access Data base. It deletes while I have the form open but close and open again and the row or rows are back. It is not deleteing from the Data-base .I am using a DataSet & Tableadapter



Private Sub btndelete_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnDelete.Click 



If Me.view.CurrentPosition > 1 Then


Dim row = CType(Me.view.CurrentItem, System.Data.DataRowView).Row

row.Delete()



End If   

End Sub

Thanks

DAvid

Ken Fitzpatrick replied to David on 19-Jul-10 04:56 PM

David,


It is not getting deleted from the database because you are only removing the row from the DatarowView. It all depends on how you are getting the data and binding it to the DataRowView. Can you post a link to the video you watched? That might help someone figure out your issue.


Ken

David replied to Ken Fitzpatrick on 20-Jul-10 11:04 AM

Thanks for your reply Ken

 | How Do I: Create a Simple Data Entry Form in WPF? is found on Visual Basic Developer Center
 The link is on the right of the page How Do I: Create a Simple Data Entry Form in WPF? Beth Massi

Visual Basic Developer Center


Thanks  David

Delete Data from Access Data-base in WPF - David replied to David on 23-Aug-10 03:03 PM

I am still at a loss of how I connect to the Access Data-base to delete a selected row using code in Xaml
I have the code from Beth Massi video which deletes the row visible

Private Sub btndelete_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnDelete.Click

                 If Me.view.CurrentPosition > 1 Then
                 Dim row = CType(Me.view.CurrentItem, System.Data.DataRowView).Row
            row.Delete()
        End If
    End Sub

I copied the following from a code sample but got stuck trying to change to my project

'Dim sqlConnection1 As New System.Data.SqlClient.SqlConnection("VB DAVE 1  main.accdb")

            ' Dim cmd As New System.Data.SqlClient.SqlCommand
            'cmd.CommandType = CommandType.StoredProcedure
            'cmd.CommandText = "DELETE Course"
            'cmd.Connection = sqlConnection1


Thanks David