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.
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.
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.
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.
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?
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.
favourLettuc...
0 Points
3 Posts
Operation must use an updateable query
Feb 12, 2013 01:20 PM|LINK
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.
<div></div>AidyF
Star
9204 Points
1570 Posts
Re: Operation must use an updateable query
Feb 12, 2013 01:41 PM|LINK
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.
hans_v
All-Star
35986 Points
6550 Posts
Re: Operation must use an updateable query
Feb 12, 2013 02:37 PM|LINK
No, you need MODIFY permissions on the folder!
http://www.mikesdotnetting.com/Article/74/Solving-the-Operation-Must-Use-An-Updateable-Query-error
hans_v
All-Star
35986 Points
6550 Posts
Re: Operation must use an updateable query
Feb 12, 2013 02:39 PM|LINK
It should be placed in the App_Data folder, or somewhere outside of the root of the website....
favourLettuc...
0 Points
3 Posts
Re: Operation must use an updateable query
Feb 13, 2013 01:01 PM|LINK
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?
hans_v
All-Star
35986 Points
6550 Posts
Re: Operation must use an updateable query
Feb 13, 2013 05:29 PM|LINK
That dsoesn't matter. Please read Mikes article?
favourLettuc...
0 Points
3 Posts
Re: Operation must use an updateable query
Feb 15, 2013 11:44 AM|LINK
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?
AidyF
Star
9204 Points
1570 Posts
Re: Operation must use an updateable query
Feb 15, 2013 12:25 PM|LINK
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.
hans_v
All-Star
35986 Points
6550 Posts
Re: Operation must use an updateable query
Feb 15, 2013 02:25 PM|LINK
Yes, you said
Please read Mikes article, and identify which user (using Environment.UserName) you need to give MODIFY permissions.....