Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Recordset update
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

TastyNutz
Junior Member

USA
251 Posts

Posted - 27 October 2007 :  21:22:50  Show Profile  Visit TastyNutz's Homepage
I have an Access db which I want to be able to view/update via an admin form. I've tried and tried again, but I keep getting the error:

"Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype."

My code:
dim business
dim currency_code
dim image_url


set cn = server.CreateObject("Adodb.Connection")
set rs = server.CreateObject("Adodb.Recordset")
cn.Open conn

strSQL = "Select * From Paypal"

If Trim(Request.QueryString("change")) = "yes" Then

rs.open strSQL,cn

If Not rs.EOF Then

rs("business") = Trim(request.Form("business"))
rs("currency_code") = request.Form("currency_code")
rs("image_url") = request.Form("image_url")

rs.Update
End If

rs.Close
Set rs = Nothing
Response.Redirect "admin_paypal.asp"
End If


I've "googled" my eyes crossed, but can't find a solution. Anyone know the answer?


PowerQuad Disability Support Forum

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 28 October 2007 :  04:06:47  Show Profile  Send ruirib a Yahoo! Message
Why don't you simply use an INSERT statement? And you should really validate form inpute before saving form input in the database.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 30 October 2007 :  13:12:38  Show Profile  Send pdrg a Yahoo! Message
It'll be the wrong cursor type (maybe a firehose cursor by default which is fast but forward only read only, as opposed to something like an updateable cursor (which uses way more system resources)). Hunt the web/db documentation for 'ADO cursor types' and you may find some. My bet is that the variable conn (which contains your connectionstring) either misses out the cursor type or has the wrong one.

Better still, do as Rui suggests and step up a level and use an INSERT with the COMMAND object in ADO instead
Go to Top of Page

TastyNutz
Junior Member

USA
251 Posts

Posted - 14 November 2007 :  16:07:46  Show Profile  Visit TastyNutz's Homepage
I'm still confused by cursor types, but during my search and from a working example, I arrived at a solution:


	rs.open strSQL, cn, 2, 3


It works, but I'm not sure why. Are the parameters in red setting the cursor type?

Please be gentle with me. I'm trying to learn.


PowerQuad Disability Support Forum
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 14 November 2007 :  17:01:31  Show Profile  Send ruirib a Yahoo! Message
Using recordset updates is much slower. Also, do not forget to validate form input, like we do in our code.


Snitz 3.4 Readme | Like the support? Support Snitz too
Go to Top of Page

TastyNutz
Junior Member

USA
251 Posts

Posted - 14 November 2007 :  19:05:57  Show Profile  Visit TastyNutz's Homepage
Thanks rui. The updates are for admin settings and product updates, so I guess performance speed isn't critical. The original code is part of a crappy product catalog that I'm building into an ecommerce template. By time I add validation and fix all of other issues, there won't be much of the original code left!


PowerQuad Disability Support Forum
Go to Top of Page

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 15 November 2007 :  11:39:55  Show Profile  Send pdrg a Yahoo! Message
http://msdn2.microsoft.com/en-us/library/ms681510.aspx
http://msdn2.microsoft.com/en-us/library/ms681771.aspx
http://msdn2.microsoft.com/en-us/library/ms681771.aspx

The 2 red variables are exactly right - the first is CursorType, the second CursorLocation. Personally I'd consider 2, 2 (the default) but if 2, 3 is working for you, all well and good.

Cursor Type 2 = adOpenDynamic
Uses a dynamic cursor. Additions, changes, and deletions by other users are visible, and all types of movement through the Recordset are allowed, except for bookmarks, if the provider doesn't support them.

ADO is a fascinating technology, it can be handy to read up about it and get to understand how it works :-) I'd still advise using an UPDATE though in terms of server stress it's a lot lighter.
Go to Top of Page

TastyNutz
Junior Member

USA
251 Posts

Posted - 15 November 2007 :  14:06:53  Show Profile  Visit TastyNutz's Homepage
Thanks for the resources. Looks like I have a little "light reading" to do.

I'm wondering if I could convince you or someone to look thru my template once it's more complete? I could really use the expertise of a real programmer to check for vulnerabilities, inefficiencies, etc. That is, if I can afford you, and you promise not to laugh at my cobbled up code!


PowerQuad Disability Support Forum
Go to Top of Page

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 16 November 2007 :  07:55:47  Show Profile  Send pdrg a Yahoo! Message
I honestly doubt if my reading your code will help much -

1) Reading someone else's code is near-impossible, ASP doubly so.
2) I'm very rusty
3) Vulns and inefficiencies I may be able to spot a couple

Sorry
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 16 November 2007 :  08:33:05  Show Profile  Visit AnonJr's Homepage
I'd go ahead and post it - the worst that happens is no one takes a look, which leaves you in the same place you were if you didn't post it. The best that happens is a bunch of people suddenly get the spare time to take a look at it and help you with some of the weak spots.

Its worth noting that unless you've commented your code well, its hard enough to read your own code let alone someone else's.... that's probably why they call it "code"!

And by "commenting well" I'm referring to quality, not quantity - there is a difference.

Its also worth noting that you may find it easier to work with the ADO constants instead of the numbers they represent. Snitz has the inc_adovbs.asp file that defines all those constants and includes them in config.asp since its easier to remember "adOpenDynamic" than "2 is the cursor type that I want".
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 16 November 2007 :  08:37:15  Show Profile  Visit AnonJr's Homepage
Oh, and don't worry about being embarrassed by your code - we all had to start somewhere, and I honestly believe that everyone has some program that they wrote when they were first starting out that holds some "embarrassing moments" - now having that and being man/woman enough to admit it are two different things.

I will admit that the LMS that I'm upgrading I wrote while I was transitioning from VB6 to ASP/VBScript and learning about web programming as I went. I'm finding a lot of code I wouldn't exactly brag about...
Go to Top of Page

TastyNutz
Junior Member

USA
251 Posts

Posted - 16 November 2007 :  10:38:15  Show Profile  Visit TastyNutz's Homepage
Thanks for the support, Anon!


PowerQuad Disability Support Forum
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.22 seconds. Powered By: Snitz Forums 2000 Version 3.4.07