Update SQL Database in SQL from datagrid
Posted on 2005-04-18
I am having trouble updating a database using a simple datagrid update function, I would be very grateful if someone can shed some light on it. I am not getting an error when i click update, it just reverts to what was in the database previously.
Here is the code. I've simplified the updateCommand for ease of understanding and chrisjones is a record in the users table.
Private Sub dgUsers_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgUsers.UpdateCommand
general.UpdateUsers("chrisjones", "Chris 2", False, False, False, False, False, False, False, True, False, True, False)
Public Shared Function UpdateUsers(ByVal username As String, ByVal fullname As String, ByVal HOU As Boolean, ByVal T01 As Boolean, ByVal T02 As Boolean, ByVal T03 As Boolean, ByVal T04 As Boolean, ByVal T05 As Boolean, ByVal T06 As Boolean, ByVal T07 As Boolean, ByVal T08 As Boolean, ByVal T09 As Boolean, ByVal INT As Boolean)
Dim Connect As New SqlConnection(DB())
Dim Adapter As SqlDataAdapter = New SqlDataAdapter
Dim myCommand As SqlCommand = New SqlCommand
myCommand.CommandText = "UPDATE users SET fullname = @fullname, HOU = @HOU,  = @Param10,  = @Param11,  = @Param12,  = @Param13,  = @Param14,  = @Param15,  = @Param16,  = @Param17,  = @Param18, INT = @INT " & _
"WHERE " & _
"(username = @username)"
myCommand.Connection = Connect
Adapter.UpdateCommand = myCommand
What am I doing wrong?