Print Page | Close Window

ADO Update Method

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=642
Printed Date: 28 March 2026 at 5:02pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: ADO Update Method
Posted By: pmormr
Subject: ADO Update Method
Date Posted: 01 March 2003 at 10:15pm

I'm writing a small script. Basically all it does is assign some variables from a query string and adds the values to a database. When call rs.addnew (rs being my recordset object) I assign my values and everything runs fine until I attempt to update the database. When I call the update method it gives me an error saying that the database doesn't support updating. I know that the database needs to support updating but how do I get it too? The database is a standard MS Access one.

Thanks,



-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/



Replies:
Posted By: joshb
Date Posted: 02 March 2003 at 12:07am
what exactly is the error msg. does it say anything about cursortype? and are you sure you have it NOT read-only, and that you hae write-permissions to the db?

-------------
I'm a wannabe programmer that knows how to do nothing but create invalid procedure arguments.
http://www.soopportal.com">


Posted By: pmormr
Date Posted: 02 March 2003 at 10:15am
it was something along the lines of "this recordset does not support updating" or "limitations of the selected locktype" i've tried changing the locktype but it didn't work. I can't exactly reproduce the error because i can't connect to an asp supporting server at this time.

-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: Ignorance
Date Posted: 02 March 2003 at 3:37pm
Check your permissions on the database file itself as well as the directory you have it in. Normally the "IUSR_machinename" account that IIS uses needs to have write access to both. I think I read somewhere around here that you can get away with giving the account full control permissions over the directory the database is in and let it propogate down.


Posted By: Bunce
Date Posted: 02 March 2003 at 4:53pm

Show us the code that is causing the error, and copy the exact error message for us to see.

This is the first thing you should do after searching the web and FAQ section for your problem, which is one of the most common found.

Cheers,
Andrew



-------------
There have been many, many posts made throughout the world...
This was one of them.


Posted By: pmormr
Date Posted: 03 March 2003 at 3:14pm

Alright, here's the code. As i said i can't provide you with the exact error message as i don't have access to a web server at this time. (The database name is changed for security purpuses) I would have provided it earlier but i needed to get access to the server and download it...

<%
  'Designed by Paul Morgan
  'in February 2003
  'inserts record (email, name, and zip)
  'into database...


  'Connect to database
  dim conn
  set conn = Server.CreateObject("ADODB.Connection")
  conn.Mode = adModeReadWrite
  conn.Provider = "Microsoft.Jet.OLEDB.4.0"
  conn.Open "c:\inetpub\myfolder\databases\mydatabase.mdb"
 
  'Open the recordset
  dim rs
  set rs = Server.CreateObject("ADODB.Recordset")
  rs.Open "list", conn

  'Create and set variables from querystring
  dim fn
  dim zip
  dim email
  fn = Request.Querystring("fname")
  zip = Request.Querystring("zip")
  email = Request.Querystring("email")

  'Add the new record to the database
  rs.AddNew
    rs ("NameFirst") = fn
 rs ("zip") = zip
 rs ("EmailAddress") = email
  rs.Update
 
  'Clean up
  rs.Close
  conn = nothing
  rs = nothing
  fn = nothing
  zip = nothing
  email = nothing
%>



-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: Bunce
Date Posted: 04 March 2003 at 1:20am

You're not specifying a locktype here:

rs.Open "list", conn

Read here for info on how to do this:
http://www.adopenstatic.com/faq/jetcursortypes.asp - http://www.adopenstatic.com/faq/jetcursortypes.asp
http://www.adopenstatic.com/faq/800a0bb9.asp#RecordsetOpenSyntax - http://www.adopenstatic.com/faq/800a0bb9.asp#RecordsetOpenSyntax

Additonally, if you're not going to iterate through your recordset, then why create a recordset at all?

You could simply execute an INSERT statement through your existing connection. Something like:

strSQL = "INSERT INTO [YourTable] ('NameFirst','Email','Zip') VALUES (' & fn & "','" & zip & "','" & email & "')"

conn.execute(strSQL)

Cheers,
Andrew



-------------
There have been many, many posts made throughout the world...
This was one of them.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net