rangerstud620
Freshman
- Joined
- Jun 14, 2005
- Messages
- 27
I'm trying to udpate an Access DB from a dropdownlist in a datagrid. When I click the Update button, I get the following error at the cmd.ExecuteNonQuery() line: "System.Data.OleDb.OleDbException: Expected query name after EXECUTE." I'm new to ASP.NET so maybe I'm way off course, but how do I fix this?
Visual Basic:
Private Sub UpdateRecord(ByVal source As Object, ByVal E As DataGridCommandEventArgs)
Dim di As DataGridItem
Dim cmd As New OleDbCommand("UPDATE NewReport SET HEADING = @HeadingID, HEADNAME = @HeadingName WHERE ID = @Id", objConnection)
Dim param As OleDbParameter
di = E.Item
cmd.CommandType = CommandType.StoredProcedure
param = cmd.Parameters.Add("@HeadingID", OleDbType.Char)
param.Value = DirectCast(di.FindControl("lstHeadings"), DropDownList).SelectedItem.Value
param = cmd.Parameters.Add("@HeadingName", OleDbType.Char)
param.Value = DirectCast(di.FindControl("lstHeadings"), DropDownList).SelectedItem.Text
param = cmd.Parameters.Add("@Id", OleDbType.Integer)
param.value = dgCompany.DataKeys(CInt(E.Item.ItemIndex))
cmd.Connection.Open()
cmd.ExecuteNonQuery() 'Errors here
dgCompany.EditItemIndex = -1
cmd.Connection.Close()
LoadGrid()
End Sub