C
Chumley the Walrus
Even tho all my field names are named right, I cannot figure why I am
getting a
"Specified argument was out of the range of valid values. Parameter
name: index" error on the line that holds " Dim sport As textbox =
E.Item.cells(2).Controls(0)". Below is the entire subroutine to
update/edit data on the datagrid in use:
Sub MyDataGrid_UpdateCommand(s As Object, e As
DataGridCommandEventArgs )
Dim conn As SqlConnection
Dim MyCommand As SqlCommand
Dim strConn as string =
"SERVER=207.42.67.18;UID=sa;PWD=mystery;DATABASE=dbHandicapperArticles;"
Dim sport As textbox = E.Item.cells(2).Controls(0)
Dim articleheader As textbox = E.Item.cells(3).Controls(0)
Dim articletext As textbox = E.Item.cells(4).Controls(0)
Dim fpick As textbox = E.Item.cells(5).Controls(0)
Dim strUpdateStmt As String
strUpdateStmt =" UPDATE tblArticles SET" & _
" sport =@sport, articleheader =@articleheader, fpick =@fpick,
articletext = @articletext " & _
" WHERE articleID = @articleID"
conn = New SqlConnection(strConn)
MyCommand = New SqlCommand(strUpdateStmt, conn)
MyCommand.Parameters.Add(New SQLParameter("@sport", sport.text))
MyCommand.Parameters.Add(New SQLParameter("@articleheader",
articleheader.text))
MyCommand.Parameters.Add(New SQLParameter("@articletext",
articletext.text))
MyCommand.Parameters.Add(New SQLParameter("@fpick", fpick.text))
MyCommand.Parameters.Add(New SQLParameter("@articleID",
e.Item.Cells(1).Text ))
conn.Open()
MyCommand.ExecuteNonQuery()
MyDataGrid.EditItemIndex = -1
conn.close
BindData
End Sub
thanks in advance
chum
getting a
"Specified argument was out of the range of valid values. Parameter
name: index" error on the line that holds " Dim sport As textbox =
E.Item.cells(2).Controls(0)". Below is the entire subroutine to
update/edit data on the datagrid in use:
Sub MyDataGrid_UpdateCommand(s As Object, e As
DataGridCommandEventArgs )
Dim conn As SqlConnection
Dim MyCommand As SqlCommand
Dim strConn as string =
"SERVER=207.42.67.18;UID=sa;PWD=mystery;DATABASE=dbHandicapperArticles;"
Dim sport As textbox = E.Item.cells(2).Controls(0)
Dim articleheader As textbox = E.Item.cells(3).Controls(0)
Dim articletext As textbox = E.Item.cells(4).Controls(0)
Dim fpick As textbox = E.Item.cells(5).Controls(0)
Dim strUpdateStmt As String
strUpdateStmt =" UPDATE tblArticles SET" & _
" sport =@sport, articleheader =@articleheader, fpick =@fpick,
articletext = @articletext " & _
" WHERE articleID = @articleID"
conn = New SqlConnection(strConn)
MyCommand = New SqlCommand(strUpdateStmt, conn)
MyCommand.Parameters.Add(New SQLParameter("@sport", sport.text))
MyCommand.Parameters.Add(New SQLParameter("@articleheader",
articleheader.text))
MyCommand.Parameters.Add(New SQLParameter("@articletext",
articletext.text))
MyCommand.Parameters.Add(New SQLParameter("@fpick", fpick.text))
MyCommand.Parameters.Add(New SQLParameter("@articleID",
e.Item.Cells(1).Text ))
conn.Open()
MyCommand.ExecuteNonQuery()
MyDataGrid.EditItemIndex = -1
conn.close
BindData
End Sub
thanks in advance
chum