tehon3299
Well-known member
I have a GUID associated with each user in my SQL database. Each user has a unique GUID and it is in every table so I can sort out what users did what actions. I am trying to delete users from an asp datagrid. Heres the code...I get an error when I try to delete a user.
Thanks
Code:
Sub MyDataGrid_DeleteCommand(s As Object, e As DataGridCommandEventArgs)
Dim strConn as String = "server=localhost;database=checking;Trusted_Connection=yes"
Dim DeleteCmd As String = "DELETE from tmUsers2 Where GUID = @Id"
Dim MyConn as New SQLConnection(strConn)
Dim Cmd as New SqlCommand(DeleteCmd, MyConn)
Cmd.Parameters.Add(New SqlParameter("@ID", MyDataGrid.DataKeys(CInt(e.Item.ItemIndex))))
MyConn.Open()
Cmd.ExecuteNonQuery()
BindData
DeleteUser(s, e)
End Sub
Sub DeleteUser(s As Object, e As DataGridCommandEventArgs)
Dim strConn as String = "server=localhost;database=checking;Trusted_Connection=yes"
Dim DeleteCmd As String = "DELETE from tmUserInfo2 Where GUID = @Id"
Dim MyConn as New SQLConnection(strConn)
Dim Cmd as New SqlCommand(DeleteCmd, MyConn)
Cmd.Parameters.Add(New SqlParameter("@ID", MyDataGrid.DataKeys(CInt(e.Item.ItemIndex))))
MyConn.Open()
Cmd.ExecuteNonQuery()
BindData
End Sub
Thanks