Dim connection As SqlConnection
Dim adapter As New SqlDataAdapter
Dim sql As String
Dim cmd As SqlCommand
Try
If Not dgvData.CurrentRow.IsNewRow Then
'Query string
sql = "delete from AccountPayable where AP_Date = '" & dgvData.CurrentRow.Cells(0).Value & "'"
'sql connection
connection = New SqlConnection("Data Source=.\sqlexpress;Initial Catalog=FinAccounting;Integrated Security=True")
connection.Open()
'command button
cmd = New SqlCommand(sql, connection)
cmd.ExecuteNonQuery()
dgvData.Rows.Remove(dgvData.CurrentRow)
MessageBox.Show("Record Deleted")
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Dim adapter As New SqlDataAdapter
Dim sql As String
Dim cmd As SqlCommand
Try
If Not dgvData.CurrentRow.IsNewRow Then
'Query string
sql = "delete from AccountPayable where AP_Date = '" & dgvData.CurrentRow.Cells(0).Value & "'"
'sql connection
connection = New SqlConnection("Data Source=.\sqlexpress;Initial Catalog=FinAccounting;Integrated Security=True")
connection.Open()
'command button
cmd = New SqlCommand(sql, connection)
cmd.ExecuteNonQuery()
dgvData.Rows.Remove(dgvData.CurrentRow)
MessageBox.Show("Record Deleted")
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try