0

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click

    If Me.dgvData.Rows.Count > 0 Then
        If Me.dgvData.SelectedRows.Count > 0 Then
            Dim intPName As Integer = Me.dgvData.SelectedRows(0).Cells("Name").Value
            If Not cnn.State = ConnectionState.Open Then
                cnn.Open()
            End If

            Dim cmd As New OleDb.OleDbCommand
            cmd.Connection = cnn
            cmd.CommandText = "DELETE FROM POS FROM [Name]=@Name" & intPName

            cmd.ExecuteNonQuery() 'syntax error occured here


            Me.RefreshData()


        End If
    End If
End Sub

Private Sub RefreshData()

    If Not cnn.State = ConnectionState.Open Then
        cnn.Open()
    End If
    Dim da As New OleDb.OleDbDataAdapter("SELECT Pname as [Name]," & _
                                         "Pnum as [Number], Qty" & _
                                         " FROM POS ORDER BY Pname", cnn)
    Dim dt As New DataTable

    da.Fill(dt)

    Me.dgvData.DataSource = dt
    cnn.Close()
End Sub
3
Contributors
2
Replies
13
Views
2 Years
Discussion Span
Last Post by DaveAmour
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.