Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 29th, 2003, 12:56 PM
Registered User
 
Join Date: Jul 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default batch update

I'm using the Beginning ASP Databases book and have written a script to perform a simple batch update and encountered the following error:

Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E25)
Row handles must all be released before new ones can be obtained.
Error occurs at 1st: objRS.MoveNext


Any ideas how to resolve it? My code is as follows:

<%@Language=VBScript%>
<% option explicit %>
<%
dim adOpenStatic, adLockBatchOptimistic
adOpenStatic = 3
adLockBatchOptimistic = 4
dim objRS
set objRS = server.createobject("adodb.recordset")
dim strSource
strSource = "Provider=SQLOLEDB.1;DRIVER={MS SQL-Server};UID=MyUserID;PWD=MyPassword;DATABASE=Sailo rs;SERVER=MyServerName"
dim sqlStorProc
sqlStorProc = "qAllBoatNames"
objRS.open sqlStorProc, strSource, adOpenStatic, adLockBatchOptimistic
response.write "1st value: " & objRS("BoatName") & "<br>"
objRS("BoatName") = "A Sweet Song"
objRS.MoveNext 'error occurs here
response.write "2nd value: " & objRS("BoatName") & "<br>"
objRS("BoatName") = "Blackbeard"
objRS.UpdateBatch
objRS.MoveFirst
response.write "Changed 1st value: " & objRS("BoatName") & "<br>"
objRS.MoveNext
response.write "Changed 2nd value: " & objRS("BoatName") & "<br>"
objRS.close
set objRS = nothing
%>


Thanks

Wills
 
Old July 30th, 2003, 04:31 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

This is apparently a bug in ADO. Try using a client-side cursor instead (by default you get a server-side cursor) by setting objRS.CursorLocation = adUseClient before opening the recordset.

See Microsoft Knowledge Base Article 257731 for details.

hth
Phil
 
Old July 30th, 2003, 09:14 AM
Registered User
 
Join Date: Jul 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Phil,

Thanks for the information. I read the article and adjusted the code:

<%@Language=VBScript%>
<% option explicit %>
<%
dim adOpenStatic, adLockBatchOptimistic, adUseClient
adOpenStatic = 3
adLockBatchOptimistic = 4
dim objRS
set objRS = server.createobject("adodb.recordset")
dim strSource
strSource = "Provider=SQLOLEDB.1;DRIVER={MS SQL-Server};UID=MyUserID;PWD=MyPassword;DATABASE=Sailo rs;SERVER=MyServerName"
dim sqlStorProc
sqlStorProc = "qAllBoatNames"
objRS.CursorLocation = adUseClient 'error occurs here
objRS.open sqlStorProc, strSource, adOpenStatic, adLockBatchOptimistic
response.write "1st value: " & objRS("BoatName") & "<br>"
objRS("BoatName") = "A Sweet Song"
objRS.MoveNext
response.write "2nd value: " & objRS("BoatName") & "<br>"
objRS("BoatName") = "Blackbeard"
objRS.UpdateBatch
objRS.MoveFirst
response.write "Changed 1st value: " & objRS("BoatName") & "<br>"
objRS.MoveNext
response.write "Changed 2nd value: " & objRS("BoatName") & "<br>"
objRS.close
set objRS = nothing
%>
---------------------------------
My new error is as follows:

Error Type:
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

Any other ideas?

Thanks,

Wills
 
Old July 30th, 2003, 11:07 AM
Registered User
 
Join Date: Jul 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I changed the code to the following:

<%@Language=VBScript%>
<% option explicit %>

<%
dim objRS
set objRS = server.createobject("adodb.recordset")
dim strSource
strSource = "Provider=SQLOLEDB.1;DRIVER={MS SQL-Server};UID=MyUserID;PWD=MyPassword;DATABASE=Sailo rs;SERVER=MyServerName"
dim sqlStorProc
sqlStorProc = "qAllBoatNames"
objRS.CursorLocation = adUseClient
objRS.open sqlStorProc, strSource, adOpenStatic, adLockBatchOptimistic
response.write "1st value: " & objRS("BoatName") & "<br>"
objRS("BoatName") = "A Sweet Song"
objRS.MoveNext
response.write "2nd value: " & objRS("BoatName") & "<br>"
objRS("BoatName") = "Blackbeard"
objRS.UpdateBatch
objRS.MoveFirst
response.write "Changed 1st value: " & objRS("BoatName") & "<br>"
objRS.MoveNext
response.write "Changed 2nd value: " & objRS("BoatName") & "<br>"
objRS.close
set objRS = nothing
%>

Now it does not appear to extract the data from the table. The first two values should be Lyric and Jacko. Instead it displays what I want to change these to and does not update the table.
 
Old July 30th, 2003, 11:11 AM
Registered User
 
Join Date: Jul 2003
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nevermind, I used the wrong stored procedure. Duh - It works fine now.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Stored procedure - batch update timeware SQL Server ASP 2 December 12th, 2007 04:13 PM
Batch File Allan320 Access 10 June 8th, 2006 06:46 AM
BATCH scapermoya Other Programming Languages 0 May 1st, 2006 08:47 PM
Batch Update to AS400 muklee Servlets 0 January 27th, 2005 09:34 PM
yet another batch update billyducs Classic ASP Databases 1 July 31st, 2003 10:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.