Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

This my code all ways delete the all data in the database please help

$
0
0
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

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>