"Operation must use an updateable query" on ExecuteNonQuery()

G

Guest

Hey all.

I'm confused. I'm trying to add a single record into an Access 2000 database
using ASP.Net. Here is the code:

objConn = New OleDbConnection(strConnect)
objConn.Open

objCommand = New OleDbCommand("INSERT INTO LOGIN_MASTER (LOGIN_ID, PWD,
F_NAME, L_NAME, TYPE_ID) VALUES ('" & strEmail & "','" & strPwd & "','" &
strFName & "','" & strLName & "','" & strType & "')",objConn)

objCommand.ExecuteNonQuery()
objConn.Close

However, when I try to run it, I get the following error:

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Operation must use an
updateable query.

It highlights the line "objCommand.ExecuteNonQuery()" as the source of the
error. That error seems entirely out of sorts for what I thought
ExecuteNonQuery() is intended for - running SQL statements against your db
that don't return recordsets. Anyone see what could be causing the problem?
 
E

Edge

MDW said:
Hey all.

I'm confused. I'm trying to add a single record into an Access 2000
database using ASP.Net. Here is the code:

objConn = New OleDbConnection(strConnect)
objConn.Open

objCommand = New OleDbCommand("INSERT INTO LOGIN_MASTER (LOGIN_ID,
PWD, F_NAME, L_NAME, TYPE_ID) VALUES ('" & strEmail & "','" & strPwd
& "','" & strFName & "','" & strLName & "','" & strType &
"')",objConn)

objCommand.ExecuteNonQuery()
objConn.Close

However, when I try to run it, I get the following error:

Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Operation must
use an updateable query.

It highlights the line "objCommand.ExecuteNonQuery()" as the source
of the error. That error seems entirely out of sorts for what I
thought ExecuteNonQuery() is intended for - running SQL statements
against your db that don't return recordsets. Anyone see what could
be causing the problem?

Admittedly, the error message is misleading.

The reason for this error message is that the process runs
under an identity (usually ASPNET) that only has read access
to the database.

Right click on the database file in Windows Explorer, go to the
Security tab, and give the ASPNET user modify rights to the file.
 
G

Guest

Ah! Yes, that was EXACTLY it! Thanks.

I know I'm new to ASP.Net, but I was starting to wonder whether I really
knew what an updateable query was. ;)
 
G

Greg Burns

Right click on the database file in Windows Explorer, go to the
Security tab, and give the ASPNET user modify rights to the file.

Remember, that Access needs to create the *.ldb (lock) file in the same
directory as the database. Giving rights to just the *.mdb may not be
enough. I like to keep my *.mdb & *.ldb in a subfolder and permission that
instead.

Greg
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top