Operation must use an updateable query

G

Guest

I keep getting this error message when I try to INSERT a record into ACCESS
on a WEB server with the following .NET code: (It works okay for SELECT
statements) I've read somewhere that it could be due to a permissions
problem but my ISP has said my code has full permissions to the .mdb file.
Can anyone suggest something ?

Dim sAppPath As String

sAppPath = Server.MapPath("\Private\gerrytest.mdb")

Dim cnn As New
OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; " & _
"data source=" & sAppPath)
Dim cmd As New OleDb.OleDbCommand
Dim sValue As String

sValue = txtSurname.Text

cmd.CommandText = "INSERT INTO Customer VALUES (" & Chr(39) & sValue
& Chr(39) & ");"

Try
cmd.Connection = cnn
cnn.Open()
cmd.ExecuteNonQuery() 'THIS IS WHERE THE ERROR OCCURS
Catch ex As Exception
sValue = ex.ToString
txtSurname.Text = sValue
Finally
cnn.Close()
End Try
 
S

Steven Licciardi

Does your table have only one column? If not then you should try :

"INSERT INTO Customer (" & ColumnName & ") VALUES ('" & sValue & "'"

Steven
 
G

Guest

It does have only one column though I did try the column name too.
Any ideas ?

Thanks
Gerry
 
S

Steven Licciardi

Afraid I don't know then. I ran your code here (created a table named
Customer, with only one column named Surname) and it worked fine.

Steven
 
S

Sylvain Lafontaine

Maybe the sValue has a single quote inside it; try using the double quote,
Chr(34), instead of Chr(39). You should display the final value of
CommandText to make sure.

It is also possible that this customer name already exists in the table.

S. L.
 
J

Jeff Dillon

No, permissions are not correct. The user your site is running under does
not have WRITE/CHANGE permissions on the \private directory.

Jeff
 
G

Guest

Hi Jeff,

Here's what I see when I type in ls -Fla for the file (from command prompt)

-rwx------ 1 Owner Group 162348 Nov 16 18:20 gerrytest.mdb*

Does this make sense (Read/Write/Execute) ?

How do I know what user-level access my .net code is running at ?
When I view the permissions of the .mdb in Internet Explorer (ftp) I see

Owner has tickboxes for Read/Write and Execute

Group and All users have none ticked.

Regards,
Gerry
 
J

Jeff Dillon

Your ISP needs to tell you what user account they are using. The permissions
listed are for "you", not the user, I suspect.

And you have command line access to the server at your ISP??

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top