Operation must use an updateable query. RRS feed

  • Question

  • User1883103525 posted

    Ok. This is very frustrating.


    I'm getting this error:

    Operation must use an updateable query.

    I've read all the possible topics on this and taken the following action:

    1. Internet Guest Account has FULL Permissions on the folder where the website and the database are hosted (not safe, but my main priority is to make it work as planned first)

    2. Internet Guest Account has FULL Permissions on Temp folder.

    3. In ODBC Manager MS Access Database > Set Advanced Options > Read Only = 0

    4. My Code does not have any joins, so errors related to those are out of question.

    5. I was able to update earlier so the Connection is prorably in the mode 3, even though I'm not sure where to put '.mode = 3'


    Here is my code:

    <%@ Page Language="VB"   debug="true"%>
    <%@ Import namespace="System.Data" %>
    <%@ Import namespace="System.Data.OleDb" %>
    <form  method="post" runat="server">
    <table width="100%">
      <tr> <td align="left"> 
          <asp:AccessDataSource ID="AccessDataSource1" runat="server" 
              DeleteCommand="DELETE FROM [Orders] WHERE [ID] = ?" 
              InsertCommand="INSERT INTO [Orders] ([ID], [EmployeeID], [CustomerID], [OrderDate], [ShipTo], [TotalHours], [ReferencePO], 
    [ReferenceQuotesFromSales], [WorkDetails], [DueDate]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" 
              SelectCommand="SELECT * FROM [Orders] ORDER BY [ID]" 
              UpdateCommand="UPDATE [Orders] SET [EmployeeID] = ?, [CustomerID] = ?, [OrderDate] = ?, [ShipTo] = ?, [TotalHours] = ?, [ReferencePO] = ?, 
    [ReferenceQuotesFromSales] = ?, [WorkDetails] = ?, [DueDate] = ? WHERE [ID] = ?">
                  <asp:Parameter Name="ID" Type="Int32" />
                  <asp:Parameter Name="ID" Type="Int32" />
                  <asp:Parameter Name="EmployeeID" Type="Int32" />
                  <asp:Parameter Name="CustomerID" Type="Int32" />
                  <asp:Parameter Name="OrderDate" Type="DateTime" />
                  <asp:Parameter Name="ShipTo" Type="Int32" />
                  <asp:Parameter Name="TotalHours" Type="String" />
                  <asp:Parameter Name="ReferencePO" Type="Int32" />
                  <asp:Parameter Name="ReferenceQuotesFromSales" Type="Int32" />
                  <asp:Parameter Name="WorkDetails" Type="String" />
                  <asp:Parameter Name="DueDate" Type="DateTime" />
                  <asp:Parameter Name="EmployeeID" Type="Int32" />
                  <asp:Parameter Name="CustomerID" Type="Int32" />
                  <asp:Parameter Name="OrderDate" Type="DateTime" />
                  <asp:Parameter Name="ShipTo" Type="Int32" />
                  <asp:Parameter Name="TotalHours" Type="String" />
                  <asp:Parameter Name="ReferencePO" Type="Int32" />
                  <asp:Parameter Name="ReferenceQuotesFromSales" Type="Int32" />
                  <asp:Parameter Name="WorkDetails" Type="String" />
                  <asp:Parameter Name="DueDate" Type="DateTime" />
                  <asp:Parameter Name="ID" Type="Int32" />
          <asp:GridView ID="GridView1" runat="server" AllowSorting="True" 
              AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ID" 
              DataSourceID="AccessDataSource1" ForeColor="#333333" GridLines="None">
              <AlternatingRowStyle BackColor="White" />
                  <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                  <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
                      ReadOnly="True" SortExpression="ID" />
                  <asp:BoundField DataField="EmployeeID" HeaderText="EmployeeID" 
                      SortExpression="EmployeeID" />
                  <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" 
                      SortExpression="CustomerID" />
                  <asp:BoundField DataField="OrderDate" HeaderText="OrderDate" 
                      SortExpression="OrderDate" />
                  <asp:BoundField DataField="ShipTo" HeaderText="ShipTo" 
                      SortExpression="ShipTo" />
                  <asp:BoundField DataField="TotalHours" HeaderText="TotalHours" 
                      SortExpression="TotalHours" />
                  <asp:BoundField DataField="ReferencePO" HeaderText="ReferencePO" 
                      SortExpression="ReferencePO" />
                  <asp:BoundField DataField="ReferenceQuotesFromSales" 
                      SortExpression="ReferenceQuotesFromSales" />
                  <asp:BoundField DataField="WorkDetails" HeaderText="WorkDetails" 
                      SortExpression="WorkDetails" />
                  <asp:BoundField DataField="DueDate" HeaderText="DueDate" 
                      SortExpression="DueDate" />
              <EditRowStyle BackColor="#7C6F57" />
              <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
              <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
              <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
              <RowStyle BackColor="#E3EAEB" />
              <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
              <SortedAscendingCellStyle BackColor="#F8FAFA" />
              <SortedAscendingHeaderStyle BackColor="#246B61" />
              <SortedDescendingCellStyle BackColor="#D4DFE1" />
              <SortedDescendingHeaderStyle BackColor="#15524A" />
    </table width="100%">
          <table id="Table1">
            <tr align="center" width="100%">
    		<td align="right"></td>
    		<td align="center">EmployeeID	</td>
    		<td align="center">CustomerID</td>
    		<td align="center">OrderDate</td>
    		<td align="center">ShipTo</td>
    		<td align="center">TotalHours</td>
    		<td align="center">ReferencePO</td>
    		<td align="center">ReferenceQuotesFromSales</td>
    		<td align="center">WorkDetails</td>
    		<td align="center">DueDate</td>
            <tr align="center" width="100%">
                <asp:Button id="btnInsert" runat="server"
                     OnClick="btnInsert_Click" text="INSERT NEW!!" />
    	  <td align="center">
                <asp:TextBox id="Field1" runat="server" width="90" align="center"/>
              <td align="center">
                <asp:TextBox id="Field2" runat="server" width="85" align="center"/>
              <td align="center">
                <asp:TextBox id="Field3" runat="server" width="95"/>
              <td align="center">
                <asp:TextBox id="Field4" runat="server" width="70"/>
              <td align="center">
                <asp:TextBox id="Field5" runat="server" width="80"/>
              <td align="center">
                <asp:TextBox id="Field6" runat="server" width="90"/>
              <td align="center">
                <asp:TextBox id="Field7" runat="server" width="180"/>
              <td align="center">
                <asp:TextBox id="Field8" runat="server" width="500"/>
              <td align="center">
                <asp:TextBox id="Field9" runat="server" width="60"/>
    <script language="VB" runat="server">
    Dim objConnection As OleDbConnection
    Sub Page_Load(Source as Object, E as EventArgs)
      objConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; " & _
                            "data source=" + MapPath("DATABASE.accdb"))
    End Sub
    Sub btnInsert_Click(Sender As Object, E As EventArgs)
      If Page.IsValid Then
        Dim strSQL As String = "INSERT INTO Orders " & _
                               "(EmployeeID, CustomerID, OrderDate, ShipTo," & _
    "TotalHours, ReferencePO, ReferenceQuotesFromSales, WorkDetails, DueDate) " & _
    "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"
    	dbcomm.mode = 3
        Dim dbComm As New OleDbCommand(strSQL, objConnection)
        dbComm.Parameters.Add("EmployeeID", OleDbType.VarChar, 20, "EmployeeID")
        dbComm.Parameters.Add("CustomerID", OleDbType.VarChar, 8, "CustomerID")
        dbComm.Parameters.Add("OrderDate", OleDbType.VarChar, 8, "OrderDate")
        dbComm.Parameters.Add("ShipTo", OleDbType.VarChar, 8, "ShipTo")
        dbComm.Parameters.Add("TotalHours", OleDbType.VarChar, 8, "TotalHours")
        dbComm.Parameters.Add("ReferencePO", OleDbType.VarChar, 20, "ReferencePO")
        dbComm.Parameters.Add("ReferenceQuotesFromSales", OleDbType.VarChar, 20, "ReferenceQuotesFromSales")
        dbComm.Parameters.Add("WorkDetails", OleDbType.VarChar, 80, "WorkDetails")
        dbComm.Parameters.Add("DueDate", OleDbType.VarChar, 8, "DueDate")
        dbComm.Parameters("EmployeeID").Value = Field1.Text
        dbComm.Parameters("CustomerID").Value = Field2.Text
        dbComm.Parameters("OrderDate").Value = Field3.Text
        dbComm.Parameters("ShipTo").Value = Field4.Text
        dbComm.Parameters("TotalHours").Value = Field5.Text
        dbComm.Parameters("ReferencePO").Value = Field6.Text
        dbComm.Parameters("ReferenceQuotesFromSales").Value = Field7.Text
        dbComm.Parameters("WorkDetails").Value = Field8.Text
        dbComm.Parameters("DueDate").Value = Field9.Text
    '    Catch ex As Exception
    '      Response.Write(ex.Message)
    '      Response.End
          If objConnection.State = ConnectionState.Open Then
          End If
        End Try
      End If
    End Sub
    <% If Session("username")="" THEN
    End If
    <script runat="server">
    Sub Log_out (Sender as Object, E as EventArgs) 
    End Sub
    <script runat="server">
        Sub Go_Back(ByVal Sender As Object, ByVal E As EventArgs)
        End Sub



    Tuesday, September 14, 2010 3:05 PM


All replies