By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,678 Members | 2,021 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,678 IT Pros & Developers. It's quick & easy.

Insert data into Access database

P: n/a
Hello,

I seem to be having a problem with inserting data, from a web form, into an
access database. I have tried
to do the same thing in a regular windows app, there it works fine, but when
I try to do the same thing in an ASP. NET form I get an error saying the
'query needs to be updateable'. The code is identical, except for a little
difference in the connection string.

Here is my code in the web form, from a button click handler:

OleDbConnection DBConnection = new OleDbConnection("Provider=Microsoft.JET.
OLEDB.4.0;Data Source=" + this.Server.MapPath("JobRegistry.mdb") + ";");
OleDbCommand cmd = new OleDbCommand("INSERT INTO Jobs (job_id, job_name,
job_num, div_id, builder, location) VALUES ('0000-000', 'test1', '3999', '2',
'OK', 'OKLOCATION')", DBConnection);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();

This generates the error message I receive:
'Operation must use an updateable query'

This is the same code used in the windows app, from a button click handler:

OleDbConnection DBConnection = new OleDbConnection("Provider=Microsoft.JET.
OLEDB.4.0;DataSource=JobRegistry.mdb");
OleDbCommand cmd = new OleDbCommand("INSERT INTO Jobs (job_id, job_name,
job_num, div_id, builder, location) VALUES ('0000-000', 'test1', '3999', '2',
'OK', 'OKLOCATION')", DBConnection);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();

This works fine.

Seems I am missing missing something somewhere. This is basically my first
attempt at working with a database source using ASP.NET and a web form. Any
help would be appreciated!

Thank You
Larry Burnett
Nov 19 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Have you tried pasting your query into a 'query' in access and running
it? Does it work ok?

Nov 19 '05 #2

P: n/a
I've had that error before, can't remember exactly how i fixed it.
Just checked the permissions on the Access file, try setting the Security on
either the .mdb file, or the folder its in.
To test, set security to allow full control to everyone, and test it then

"Larry B via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in message
news:52***********@DotNetMonster.com...
Hello,

I seem to be having a problem with inserting data, from a web form, into
an
access database. I have tried
to do the same thing in a regular windows app, there it works fine, but
when
I try to do the same thing in an ASP. NET form I get an error saying the
'query needs to be updateable'. The code is identical, except for a little
difference in the connection string.

Here is my code in the web form, from a button click handler:

OleDbConnection DBConnection = new
OleDbConnection("Provider=Microsoft.JET.
OLEDB.4.0;Data Source=" + this.Server.MapPath("JobRegistry.mdb") + ";");
OleDbCommand cmd = new OleDbCommand("INSERT INTO Jobs (job_id, job_name,
job_num, div_id, builder, location) VALUES ('0000-000', 'test1', '3999',
'2',
'OK', 'OKLOCATION')", DBConnection);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();

This generates the error message I receive:
'Operation must use an updateable query'

This is the same code used in the windows app, from a button click
handler:

OleDbConnection DBConnection = new
OleDbConnection("Provider=Microsoft.JET.
OLEDB.4.0;DataSource=JobRegistry.mdb");
OleDbCommand cmd = new OleDbCommand("INSERT INTO Jobs (job_id, job_name,
job_num, div_id, builder, location) VALUES ('0000-000', 'test1', '3999',
'2',
'OK', 'OKLOCATION')", DBConnection);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();

This works fine.

Seems I am missing missing something somewhere. This is basically my first
attempt at working with a database source using ASP.NET and a web form.
Any
help would be appreciated!

Thank You
Larry Burnett

Nov 19 '05 #3

P: n/a
Hello Larry !

It is working with your windows app, because the user which is running your application is _you_.
In a web application, your application is run by a process named aspnet_wp.exe. This process
runs using a specific account (normally ASPNET). So, to fix your problem, try to grant access in
write mode for the user ASPNET on your access file.

It should work.....

Best Regards

Yves Peneveyre
Larry B via DotNetMonster.com<fo***@DotNetMonster.com> 10.08.2005 15:13:10 >>>

Hello,

I seem to be having a problem with inserting data, from a web form, into an
access database. I have tried
to do the same thing in a regular windows app, there it works fine, but when
I try to do the same thing in an ASP. NET form I get an error saying the
'query needs to be updateable'. The code is identical, except for a little
difference in the connection string.

Here is my code in the web form, from a button click handler:

OleDbConnection DBConnection = new OleDbConnection("Provider=Microsoft.JET.
OLEDB.4.0;Data Source=" + this.Server.MapPath("JobRegistry.mdb") + ";");
OleDbCommand cmd = new OleDbCommand("INSERT INTO Jobs (job_id, job_name,
job_num, div_id, builder, location) VALUES ('0000-000', 'test1', '3999', '2',
'OK', 'OKLOCATION')", DBConnection);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();

This generates the error message I receive:
'Operation must use an updateable query'

This is the same code used in the windows app, from a button click handler:

OleDbConnection DBConnection = new OleDbConnection("Provider=Microsoft.JET.
OLEDB.4.0;DataSource=JobRegistry.mdb");
OleDbCommand cmd = new OleDbCommand("INSERT INTO Jobs (job_id, job_name,
job_num, div_id, builder, location) VALUES ('0000-000', 'test1', '3999', '2',
'OK', 'OKLOCATION')", DBConnection);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();

This works fine.

Seems I am missing missing something somewhere. This is basically my first
attempt at working with a database source using ASP.NET and a web form. Any
help would be appreciated!

Thank You
Larry Burnett
Nov 19 '05 #4

P: n/a
On Wed, 10 Aug 2005 13:13:10 GMT, "Larry B via DotNetMonster.com" <fo***@DotNetMonster.com> wrote:

Hello,

I seem to be having a problem with inserting data, from a web form, into an
access database. I have tried
to do the same thing in a regular windows app, there it works fine, but when
I try to do the same thing in an ASP. NET form I get an error saying the
'query needs to be updateable'. The code is identical, except for a little
difference in the connection string.

Here is my code in the web form, from a button click handler:

OleDbConnection DBConnection = new OleDbConnection("Provider=Microsoft.JET.
OLEDB.4.0;Data Source=" + this.Server.MapPath("JobRegistry.mdb") + ";");
OleDbCommand cmd = new OleDbCommand("INSERT INTO Jobs (job_id, job_name,
job_num, div_id, builder, location) VALUES ('0000-000', 'test1', '3999', '2',
'OK', 'OKLOCATION')", DBConnection);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();

This generates the error message I receive:
'Operation must use an updateable query'


See the following:

http://support.microsoft.com/default...b;en-us;316675
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 19 '05 #5

P: n/a
Hi,

I had a similar problem. After reading your response I looked at the users
of my Windows XP. Indeed there was a user ASPNET_WP with limited rights.
After changing the account type to Computer administrator, everything worked
fine.

Thank for your help.

ASP newbie
"Yves Peneveyre" <Yves dot Peneveyre at ctp dot com> wrote in message
news:42******************@ctp.com...
Hello Larry !

It is working with your windows app, because the user which is running your
application is _you_.
In a web application, your application is run by a process named
aspnet_wp.exe. This process
runs using a specific account (normally ASPNET). So, to fix your problem,
try to grant access in
write mode for the user ASPNET on your access file.

It should work.....

Best Regards

Yves Peneveyre
Larry B via DotNetMonster.com<fo***@DotNetMonster.com> 10.08.2005

15:13:10 >>>
Hello,

I seem to be having a problem with inserting data, from a web form, into an
access database. I have tried
to do the same thing in a regular windows app, there it works fine, but when
I try to do the same thing in an ASP. NET form I get an error saying the
'query needs to be updateable'. The code is identical, except for a little
difference in the connection string.

Here is my code in the web form, from a button click handler:

OleDbConnection DBConnection = new OleDbConnection("Provider=Microsoft.JET.
OLEDB.4.0;Data Source=" + this.Server.MapPath("JobRegistry.mdb") + ";");
OleDbCommand cmd = new OleDbCommand("INSERT INTO Jobs (job_id, job_name,
job_num, div_id, builder, location) VALUES ('0000-000', 'test1', '3999',
'2',
'OK', 'OKLOCATION')", DBConnection);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();

This generates the error message I receive:
'Operation must use an updateable query'

This is the same code used in the windows app, from a button click handler:

OleDbConnection DBConnection = new OleDbConnection("Provider=Microsoft.JET.
OLEDB.4.0;DataSource=JobRegistry.mdb");
OleDbCommand cmd = new OleDbCommand("INSERT INTO Jobs (job_id, job_name,
job_num, div_id, builder, location) VALUES ('0000-000', 'test1', '3999',
'2',
'OK', 'OKLOCATION')", DBConnection);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();

This works fine.

Seems I am missing missing something somewhere. This is basically my first
attempt at working with a database source using ASP.NET and a web form. Any
help would be appreciated!

Thank You
Larry Burnett
Nov 19 '05 #6

P: n/a
Hello !

I think it is not the best solution.
As I understand what you did, you added the ASPNET account into the Administrators group.
This is not very good, because all your web applications will run with privileged rights.
I suggested to add the write rights on the Access file for the ASPNET account.
But, anyway, if it is working......that's fine !
Yves Peneveyre
ASP Newbie<Lo************@chello.nl> 10.08.2005 16:09:21 >>> Hi,

I had a similar problem. After reading your response I looked at the users
of my Windows XP. Indeed there was a user ASPNET_WP with limited rights.
After changing the account type to Computer administrator, everything worked
fine.

Thank for your help.

ASP newbie
"Yves Peneveyre" <Yves dot Peneveyre at ctp dot com> wrote in message
news:42******************@ctp.com...
Hello Larry !

It is working with your windows app, because the user which is running your
application is _you_.
In a web application, your application is run by a process named
aspnet_wp.exe. This process
runs using a specific account (normally ASPNET). So, to fix your problem,
try to grant access in
write mode for the user ASPNET on your access file.

It should work.....

Best Regards

Yves Peneveyre
Larry B via DotNetMonster.com<fo***@DotNetMonster.com> 10.08.2005

15:13:10 >>>
Hello,

I seem to be having a problem with inserting data, from a web form, into an
access database. I have tried
to do the same thing in a regular windows app, there it works fine, but when
I try to do the same thing in an ASP. NET form I get an error saying the
'query needs to be updateable'. The code is identical, except for a little
difference in the connection string.

Here is my code in the web form, from a button click handler:

OleDbConnection DBConnection = new OleDbConnection("Provider=Microsoft.JET.
OLEDB.4.0;Data Source=" + this.Server.MapPath("JobRegistry.mdb") + ";");
OleDbCommand cmd = new OleDbCommand("INSERT INTO Jobs (job_id, job_name,
job_num, div_id, builder, location) VALUES ('0000-000', 'test1', '3999',
'2',
'OK', 'OKLOCATION')", DBConnection);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();

This generates the error message I receive:
'Operation must use an updateable query'

This is the same code used in the windows app, from a button click handler:

OleDbConnection DBConnection = new OleDbConnection("Provider=Microsoft.JET.
OLEDB.4.0;DataSource=JobRegistry.mdb");
OleDbCommand cmd = new OleDbCommand("INSERT INTO Jobs (job_id, job_name,
job_num, div_id, builder, location) VALUES ('0000-000', 'test1', '3999',
'2',
'OK', 'OKLOCATION')", DBConnection);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();

This works fine.

Seems I am missing missing something somewhere. This is basically my first
attempt at working with a database source using ASP.NET and a web form. Any
help would be appreciated!

Thank You
Larry Burnett
Nov 19 '05 #7

P: n/a
Thanks Paul,

I followed the link and one of the resolutions took care of the problem. I
did set the 'processModel' to 'SYSTEM' and that does seem to work good. I
appreciate the help from you and everyone that helped with this issue. I
have been struggling for days trying to figure it out. Finally over the hump
(whew)!

Thanks Again!
Larry Burnett

Paul Clement wrote:
Hello,

I seem to be having a problem with inserting data, from a web form, into an
access database. I have tried
to do the same thing in a regular windows app, there it works fine, but when
I try to do the same thing in an ASP. NET form I get an error saying the
'query needs to be updateable'. The code is identical, except for a little
difference in the connection string.

Here is my code in the web form, from a button click handler:

OleDbConnection DBConnection = new OleDbConnection("Provider=Microsoft.JET.
OLEDB.4.0;Data Source=" + this.Server.MapPath("JobRegistry.mdb") + ";");
OleDbCommand cmd = new OleDbCommand("INSERT INTO Jobs (job_id, job_name,
job_num, div_id, builder, location) VALUES ('0000-000', 'test1', '3999', '2',
'OK', 'OKLOCATION')", DBConnection);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();

This generates the error message I receive:
'Operation must use an updateable query'


See the following:

http://support.microsoft.com/default...b;en-us;316675

Paul
~~~~
Microsoft MVP (Visual Basic)

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.