467,146 Members | 991 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,146 developers. It's quick & easy.

updating a access Database Record

Question about updating a access Database Record!
Normally i'm working with SQLserver, but i have to do this with access and it's not working.

My error is: Operation must use an updateable query.

This is my code:
Dim objCommand As OleDbCommand
Dim strSQLQuery As String

' Our insert command
strSQLQuery = "Update Regios SET Regio=@TextRegio WHERE RegioID=@RegioID "

' Create new command object passing it our SQL insert
' and telling it which connection to use.

objCommand = New OleDbCommand(strSQLQuery, conStoreAdmin)

' Add parameters that our SQL command takes:
objCommand.Parameters.Add(New OleDbParameter("@TextRegio", OleDbType.VarChar, 500))
objCommand.Parameters.Add(New OleDbParameter("@RegioID", OleDbType.Integer))

' Set the values of these parameters:
objCommand.Parameters("@TextRegio").Value = strKAT
objCommand.Parameters("@RegioID").Value = intID

' Open the connection, execute the command, and close the connection.
conStoreAdmin.Open()
objCommand.ExecuteNonQuery()
conStoreAdmin.Close()

Thx

Nov 21 '05 #1
  • viewed: 1237
Share:
6 Replies
On Wed, 2 Feb 2005 15:42:11 +0100, "Fred Geurtsen" <f.********@simstones.nl> wrote:

Question about updating a access Database Record!
Normally i'm working with SQLserver, but i have to do this with access and it's not working.

My error is: Operation must use an updateable query.

This is my code:
Dim objCommand As OleDbCommand
Dim strSQLQuery As String

' Our insert command
strSQLQuery = "Update Regios SET Regio=@TextRegio WHERE RegioID=@RegioID "

' Create new command object passing it our SQL insert
' and telling it which connection to use.

objCommand = New OleDbCommand(strSQLQuery, conStoreAdmin)

' Add parameters that our SQL command takes:
objCommand.Parameters.Add(New OleDbParameter("@TextRegio", OleDbType.VarChar, 500))
objCommand.Parameters.Add(New OleDbParameter("@RegioID", OleDbType.Integer))

' Set the values of these parameters:
objCommand.Parameters("@TextRegio").Value = strKAT
objCommand.Parameters("@RegioID").Value = intID

' Open the connection, execute the command, and close the connection.
conStoreAdmin.Open()
objCommand.ExecuteNonQuery()
conStoreAdmin.Close()

Could be permissions issue on the folder or database file. Is this an ASP.NET application?
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 21 '05 #2
Yes, It is an ASP.NET application, so my access database file can't be
written. Do I need to share and allow changing the folder where my
database is?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #3


"Fred Geurtsen" <fa********@zonnet.nl> wrote in message
news:uk**************@tk2msftngp13.phx.gbl...
Yes, It is an ASP.NET application, so my access database file can't be
written. Do I need to share and allow changing the folder where my
database is?

You also need a primary key.
If you have one then the next thing to try is just executing a hard coded
string and check that doesn't work.

When you write to an access database that user has to create an ldb file in
the same folder as the mdb and be able to write the user locks away to that.
The last user disconnecting also deletes the ldb with recent versions of
access.
There's no database service.

--
Regards,
Andy O'Neill
Nov 21 '05 #4
If it is an ASP.NET app you may even need to edit the machine.config file.

Did you make it work?
"Andy O'Neill" <ao***************@lycos.co.uk> wrote in message
news:9r*************@fe3.news.blueyonder.co.uk...


"Fred Geurtsen" <fa********@zonnet.nl> wrote in message
news:uk**************@tk2msftngp13.phx.gbl...
Yes, It is an ASP.NET application, so my access database file can't be
written. Do I need to share and allow changing the folder where my
database is?

You also need a primary key.
If you have one then the next thing to try is just executing a hard coded
string and check that doesn't work.

When you write to an access database that user has to create an ldb file
in the same folder as the mdb and be able to write the user locks away to
that. The last user disconnecting also deletes the ldb with recent
versions of access.
There's no database service.

--
Regards,
Andy O'Neill

Nov 21 '05 #5
Fred Geurtsen wrote:
Question about updating a access Database Record!
Normally i'm working with SQLserver, but i have to do this with access
and it's not working.

My error is: *Operation must use an updateable query.*
**
This is my code:

Dim objCommand As OleDbCommand
Dim strSQLQuery As String

' Our insert command
strSQLQuery = "Update Regios SET Regio=@TextRegio WHERE RegioID=@RegioID "

' Create new command object passing it our SQL insert
' and telling it which connection to use.

objCommand = New OleDbCommand(strSQLQuery, conStoreAdmin)

' Add parameters that our SQL command takes:
objCommand.Parameters.Add(New OleDbParameter("@TextRegio",
OleDbType.VarChar, 500))
objCommand.Parameters.Add(New OleDbParameter("@RegioID", OleDbType.Integer))

' Set the values of these parameters:
objCommand.Parameters("@TextRegio").Value = strKAT
objCommand.Parameters("@RegioID").Value = intID

' Open the connection, execute the command, and close the connection.
conStoreAdmin.Open()
objCommand.ExecuteNonQuery()
conStoreAdmin.Close()

Thx

I believe when using Access DB you need to use a question mark in the
select query to indicate a parameter.
Nov 21 '05 #6
On Wed, 02 Feb 2005 08:05:00 -0800, Fred Geurtsen <fa********@zonnet.nl> wrote:

Yes, It is an ASP.NET application, so my access database file can't be
written. Do I need to share and allow changing the folder where my
database is?

If you're not using impersonation for your web application (configured via the web.config) then you
need to provide full file access to the folder where the Access database is located for the ASPNET
account. This is the default identity under which your ASP.NET web application executes if you are
not implementing impersonation, and it is a somewhat restricted account.
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by Jason | last post: by
5 posts views Thread by junglist | last post: by
2 posts views Thread by barret bonden | last post: by
1 post views Thread by rdemyan via AccessMonster.com | last post: by
1 post views Thread by talat.riaz@gmail.com | last post: by
4 posts views Thread by MooVBuff | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.