Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rowset position cannot be restarted

Status
Not open for further replies.

obuspider

Programmer
Oct 31, 2002
78
US
I am getting an error "rowset position cannot be restarted". The following is the bit of code I'm using. I have been able to get it to work without using sessions and just doing a response.write. I need to get it working using sessions because this is how the app was built in order to display reports using Crystal Reports. I'm stuck on this. Any help would be greatly appreciated.


Set oConn = Server.CreateObject( "ADODB.Connection" )
Set objCmd = Server.CreateObject( "ADODB.Command" )
Set session("oRs") = Server.CreateObject( "ADODB.Recordset" )

sConn = "uid=Foodsrvc;pwd=gA15L6;dsn=StockStatus"
oConn.Open sConn
objCmd.ActiveConnection = oConn
objCmd.CommandTimeout = 180


with objCmd
.commandText = "ProcTrackingOverview "
.CommandType = &H0004
.parameters(1) = Cdate(fsale_date)
.parameters(2) = CDate(tsale_date)

End With
Set session("oRs")= objCmd.Execute()
'objCmd = nothing

if not session("oRs").eof then
session("oRs").movefirst
 
You don't need the line:session("oRs").movefirst
It is causing the error.... -- Just trying to help...
[wolf]<--- This is a wolf? We need a new icon.......
mikewolf@tst-us.com
 
Thanks for the tip. Now the page is just hanging. Here's the rest of the code on that page. Any ideas.


OptCH = &quot;2&quot;
OptCH1 = &quot;1&quot;
fsale_date = &quot;10/7/02&quot;
tsale_date = &quot;10/8/02&quot;
selReg = &quot;E&quot;
txtarea = &quot;13W&quot;

reportname=&quot;../Reports/Region.rpt&quot;


Set oConn = Server.CreateObject( &quot;ADODB.Connection&quot; )
Set objCmd = Server.CreateObject( &quot;ADODB.Command&quot; )
Set session(&quot;oRs&quot;) = Server.CreateObject( &quot;ADODB.Recordset&quot; )

sConn = &quot;uid=Foodsrvc;pwd=gA15L6;dsn=StockStatus&quot;
oConn.Open sConn
objCmd.ActiveConnection = oConn
objCmd.CommandTimeout = 180


with objCmd
.commandText = &quot;ProcTrackingOverview &quot;
.CommandType = &H0004
.parameters(1) = Cdate(fsale_date)
.parameters(2) = CDate(tsale_date)

End With
Set session(&quot;oRs&quot;)= objCmd.Execute()
'objCmd = nothing

if not session(&quot;oRs&quot;).eof then


Set session(&quot;oApp&quot;) = Server.CreateObject(&quot;Crystal.CRPE.Application&quot;)

Path = Request.ServerVariables(&quot;PATH_TRANSLATED&quot;)
'response.write path & &quot;<br>&quot;
While Right(Path, 1) <> &quot;\&quot; And Len(Path) <> 0
iLen = Len(Path) - 1
Path = Left(Path, iLen)

Wend
'response.write path
If IsObject(session(&quot;oRpt&quot;)) then
Set session(&quot;oRpt&quot;) = nothing
End if

Set session(&quot;oRpt&quot;) = session(&quot;oApp&quot;).OpenReport(path&reportname,1)

session(&quot;oRpt&quot;).DiscardSavedData
set Database = session(&quot;oRpt&quot;).Database
set Tables = Database.Tables
set Table1 = Tables.Item(1)
Table1.SetPrivateData 3,session(&quot;oRs&quot;)
session(&quot;oRpt&quot;).ReadRecords
session(&quot;oRpt&quot;).DiscardSavedData
On Error Resume Next
If Err.Number <> 0 Then
Response.Write &quot;An Error has occured on the server in attempting to access the data source&quot;
Else
If IsObject(session(&quot;oPageEngine&quot;)) Then
set session(&quot;oPageEngine&quot;) = nothing
End If
set session(&quot;oPageEngine&quot;) = session(&quot;oRpt&quot;).PageEngine
End If
%>
<!-- #include file=&quot;SmartViewerActiveX1.asp&quot; -->
<%
'else
'response.redirect &quot;no_rec_found.asp&quot;
'end if


set oConn = nothing
set session(&quot;oapp&quot;)=nothing
set session(&quot;ors&quot;)=nothing
 
I don't see anything that is hanging it here. Usually people have when moving through a recordset with a DO WHILE NOT objRS.EOF....LOOP structure and forgetting to advance the recordset with a objRS.MOVENEXT statement. I don't see that here. You might want to try inserting:

response.write &quot;You are here&quot;
response.end 'All code after this will not execute

into your code at different levels so you can isolate when it starts hanging.. -- Just trying to help...
[wolf]<--- This is a wolf? We need a new icon.......
mikewolf@tst-us.com
 
You may want to look into using a type flag on your recordset to manually set it to adCmdStatic (static recordset). It may be possible that you are getting a recordset with the command type set to forward reading only. w3schools has a pretty good breakdown of the ADO object in their ADO reference, including flags and such for recordsets, connections, and command objects.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
For my next trick I will pull a hat out of a rabbit (if you think thats bad you should see how the pigeon feels...) :p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top