Instar a record in Access

  • Thread starter Thread starter Carlos
  • Start date Start date
C

Carlos

Hi!

When I execute a INSERT statement this error is display: "Operation must
use an updateable query"
The Server is a Windows 2003
The users of ASP.NET and IU_...... is in Administrators groups!
The database is Access 2003.
Can you help me please?

This is the code:

<% @Page Language = VB debug=true%>
<% @Import Namespace="System.Data"%>
<% @Import Namespace="System.Data.OLEDB"%>

<Script Runat=Server>
Sub Page_Load(sender As Object, e As EventArgs)

dim cnn as oledbconnection
dim cmd as oledbcommand
dim tabla as string

cnn = new oledbconnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" &
Server.MapPath("datos.mdb") & ";")
cmd = new oledbcommand("insert into table (field) values ('test')")

cmd.connection=cnn
cmd.connection.open()
cmd.executenonquery()

end sub
</Script>
 
Hi Carlos,

From your description, you encountered the "Operation must use an
updateable query" when try to use OleDbCommand to insert a record into an
access database, yes?

Since you're manipulating it in ASP.NET web application and is on an
Windows server 2003 machine, I think the problem is likely due to security
issue. I think we can perform the following steps first:

1. Test it in a winform application to see whether it works, this can
confirm whether it's specified to the mdb file or the asp.net web
application.

2. In W2K3 server machine(with iis6) ,yes? The default asp.net workproces
is NetWorkService rather than Machine\aspnet, please have a further check
to see whether you've grant the sufficient permission to this workprocess
account .

3. I've met a former issue similiar with this and it resolved by add the
write permission to the mdb file to Everyone group. I think you may also
have a try on this.

If you have any other new findings, please also feel free to post here.
Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
Yes, the table have a Primary Key :(

William Ryan eMVP said:
Do you have a primary key on the table? Another thing you may want to do is
avoid the hard coded values and opt for Parameterized queries instead. Let
me know if you have a key b/c if you do, then that's not the problem
although it is the most likely culprit.

HTH,

Bill

--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
http://www.devbuzz.com/content/zinc_personal_media_center_pg1.asp
Source="
 
At the moment the problem is solved with the Everyone group!!!! and to
enable its write rights.

I will to investigate the problem, when I found the solution, I will
communicate it to you.

Thanks!
 
Hi Carlos,

Thanks for your followup. Since granting write permission to everyone group
has resolved the problem, I think the problem is likely that when you
execute the update/insert statemetn, the asp.net is under a different
account than the one which has the sufficient permission. I think you can
use Filemon to have a track on it.
Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
Hi Steven,
I replaced the group Everyone by IIS_WPG with rights to write and it work
perfect!

But.... that is the account IIS_WPG?
 
Hi Carlos,

Thanks for the followup. As I've mentioned that in IIS6 the ASP.NET by
default run under the NetWorkService account rather than the machine\aspnet
account. And the NetWorkService account is just in the IIS_WPG group. And
this account can also be replaced in the IIS6's application pool setting.
So I think you can also try grant the permission to NetworkService account
rather than the IISWPG group to see whether this works. Also, here is the
reference on the process Identity setting in IIS6's application Pool
configuration:

#Identity Application Pool Settings
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconidentityapplicatio
npoolsettings.asp?frame=true

Hope also helps. Thanks.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
Hi Carlos,

Have you had a chance to check out the suggestions in my last reply or have
you got any further ideas on this issue? If you have anything unclear or if
there're anything else we can help, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
Back
Top