locked
Operation must use an updateable query RRS feed

  • Question

  • User-751672518 posted

    This error occurs during execution of the code below:

    public static bool addCustomer(string nric, string name, string email, UInt64 phone)
            {
                string commStr = "Insert into Customer (NricNo, CustName, Email, Phone) values (@nric, @name, @email, @phone)";
                OleDbConnection dbConn = new OleDbConnection(connStr);
                OleDbCommand dbComm = new OleDbCommand(commStr, dbConn);
                dbComm.Parameters.AddWithValue("@nric", nric);
                dbComm.Parameters.AddWithValue("@name", name);
                dbComm.Parameters.AddWithValue("@email", email);
                dbComm.Parameters.AddWithValue("@phone", phone);
    
                try
                {
                    dbConn.Open();
    
                    if (dbComm.ExecuteNonQuery() > 0)
                        return true;
                    else
                        return false;
                }
                finally
                {
                    dbConn.Close();
                }
            }
    


    I tried placing the Access database in various locations such as the following but to no avail:

    "C:\Users\user\Documents\Visual Studio 2010\Projects\WebForm2",

    "C:\Users\user\Documents\Visual Studio 2010\Projects\WebForm2\WebForm2\bin", 

    "C:\Users\user\Documents\Visual Studio 2010\Projects\WebForm2\WebForm2\App_Data"

    Reading of data was fine but occurs only if I place the database in "C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0". I thought it should be in the \bin of the application folder or perhaps "App_Data".

    Hope someone is able to provide some advice on this problem. Thanks.


    Tuesday, February 12, 2013 9:20 AM

Answers

  • User-1199946673 posted

    favourLettuce

    Have already set the permission levels  to "read/write" but still got the same error.

    Yes, you said

    favourLettuce

    In the Security tab, full control is given to "Everyone", "System", "Administrator", "All application packages".

    Please read Mikes article, and identify which user (using Environment.UserName) you need to give MODIFY permissions.....

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 15, 2013 10:25 AM

All replies

  • User-760709272 posted

    Make sure the account your code is running under (probably the anonymous user account) has write access not only to the MDB file, but also the folder in which it is located.

    Tuesday, February 12, 2013 9:41 AM
  • User-1199946673 posted

    Make sure the account your code is running under (probably the anonymous user account) has write access not only to the MDB file, but also the folder in which it is located.

    No, you need MODIFY permissions on the folder!

    http://www.mikesdotnetting.com/Article/74/Solving-the-Operation-Must-Use-An-Updateable-Query-error

    Tuesday, February 12, 2013 10:37 AM
  • User-1199946673 posted

    I thought it should be in the \bin of the application folder or perhaps "App_Data".

    It should be placed in the App_Data folder, or somewhere outside of the root of the website....

    Tuesday, February 12, 2013 10:39 AM
  • User-751672518 posted

    I had placed the Access DB file in App_Data and under Properties --> Share tab, set "read/write" permissions for "user", "Everyone" and "All application packages". In the Security tab, full control is given to "Everyone", "System", "Administrator", "All application packages".

    The error still occurs. I'm able to read the data but not write. Is read and write within the same location?

    As mentioned earlier, reading is not within App_Data since the program had earlier prompted me to save the Access DB file in C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0.

    Which other locations could this file be stored?

    Wednesday, February 13, 2013 9:01 AM
  • User-1199946673 posted

    Which other locations could this file be stored?

    That dsoesn't matter. Please read Mikes article?

    Wednesday, February 13, 2013 1:29 PM
  • User-751672518 posted

    Have already set the permission levels  to "read/write" but still got the same error. I noticed that the App_Data folder is "read-only" even though I've unchecked and apply the change. Is there anything to do with that?

    Friday, February 15, 2013 7:44 AM
  • User-760709272 posted

    When you use the MDB file it will create an LDB file to manage the locks etc, and this is the reason you need write access to the folder itself, not just the mdb file.  If your app_data folder is read-only then that will stop your code from working.

    Friday, February 15, 2013 8:25 AM
  • User-1199946673 posted

    favourLettuce

    Have already set the permission levels  to "read/write" but still got the same error.

    Yes, you said

    favourLettuce

    In the Security tab, full control is given to "Everyone", "System", "Administrator", "All application packages".

    Please read Mikes article, and identify which user (using Environment.UserName) you need to give MODIFY permissions.....

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 15, 2013 10:25 AM
  • User604541633 posted

    Give administrator permission to folder that contain your database file. 

    Just right click on db file -> Properties -> Security Tab

    Here are 5 solutions to solve this error:

    http://www.infolet.org/2013/06/fix-ms-access-operation-must-use-an-updateable-query-problem-error.html

    Friday, June 28, 2013 11:04 PM