i used v s 2010 i have one problem..when i delete more then one rows from backend database using datagridview's checkbox....when i delete continus more then one row it maintain a my field NO in backend.......
but suppose when i delete a row 2 and 4 then.......it can not maintain a backend..... my programming is that *When i delete a row then all then getherthan of that row s No field Number is like n=n-1 *
my code is here....can any one solve it.....
Dim i, j, n As Integer
i = 0
j = 0
Dim x As Integer = 0
Dim a(1000) As String
a(x) = ""
Try
While i < DataGridView1.Rows.Count
If DataGridView1.Rows(i).Cells(0).Value() Then
n = DataGridView1.Rows(i).Cells(1).Value()
Call openconnection()
'Here It Will Delete your Row From The Database Depending On Your Id....
str = "DELETE FROM Assets_Detail Where No=" & n & ""
cmd = New SqlCommand(str, cn)
cmd.ExecuteNonQuery()
a(x) = n.ToString
cn.Close()
x = x + 1
End If
i = i + 1
End While
Catch ex As Exception
MsgBox(ex.ToString())
End Try
While j <= Val(a(x))
Dim temp As Integer
temp = Val(a(x))
Call openconnection()
str = "update Assets_Detail set No=No-1 where No > " & temp & ""
cmd = New SqlCommand(str, cn)
cmd.ExecuteNonQuery()
cn.Close()
j = j + 1
End While