adamdavies
Programmer
trying to use update on datagrid
i get an error on FNameTextBox = E.Item.Cells(3).Controls(0)
Dim editkey As String
Dim FNameTextBox As TextBox
Dim SNameTextBox As TextBox
editkey = dgusers.DataKeys(E.Item.ItemIndex)
FNameTextBox = E.Item.Cells(3).Controls(0)
SNameTextBox = E.Item.Cells(4).Controls(0)
Dim strSQL As String = "Update QuickQuery Set FName='" & FNameTextBox.Text & "', SName = '" & SNameTextBox.Text & "' WHERE EmpCDate= '" & editkey & "'"
Dim objConn As New OleDbConnection(strConn)
Dim objCmd As New OleDbCommand(strSQL, objConn)
objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()
dgusers.BackColor = System.Drawing.Color.White
dgusers.EditItemIndex = -1
DataBind()
does anybody know where i am going wrong, can supply more info
thanks
adam
i get an error on FNameTextBox = E.Item.Cells(3).Controls(0)
Dim editkey As String
Dim FNameTextBox As TextBox
Dim SNameTextBox As TextBox
editkey = dgusers.DataKeys(E.Item.ItemIndex)
FNameTextBox = E.Item.Cells(3).Controls(0)
SNameTextBox = E.Item.Cells(4).Controls(0)
Dim strSQL As String = "Update QuickQuery Set FName='" & FNameTextBox.Text & "', SName = '" & SNameTextBox.Text & "' WHERE EmpCDate= '" & editkey & "'"
Dim objConn As New OleDbConnection(strConn)
Dim objCmd As New OleDbCommand(strSQL, objConn)
objConn.Open()
objCmd.ExecuteNonQuery()
objConn.Close()
dgusers.BackColor = System.Drawing.Color.White
dgusers.EditItemIndex = -1
DataBind()
does anybody know where i am going wrong, can supply more info
thanks
adam