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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help needed with recordset

Status
Not open for further replies.

emissions

Technical User
Mar 17, 2002
68
0
0
GB
Hi,

I have a page that sends a variable via a url link

<a href="status.asp?status=PRO">link</a>

this displays the correct results on the status, now when goto post the same results to an csv file, I get BOF.EOF error stating that there is no records or they have delete, can anyone help?
 
Any particular reason to use ADO on that file?

Why not just use FSO and the TextStream.
 
<%
Dim rsStatus__VarStatus
rsStatus__VarStatus = "0"
If (Request.QueryString("status") <> "") Then
rsStatus__VarStatus = Request.QueryString("status")
End If
%>
<%
Dim rsStatus
Dim rsStatus_numRows

Set rsStatus = Server.CreateObject("ADODB.Recordset")
rsStatus.ActiveConnection = MM_Assist_STRING
rsStatus.Source = "SELECT dbo.tblJobInstructions#1.JobNumber, dbo.tblJobInstructions#1.StatusDate, dbo.tblSites.SiteName, dbo.tblSites.SiteNotes, dbo.tblFeatures.FeatureName, dbo.tblJobCategory1.JobCategory1Description, dbo.tblJobInstructions#1.JobStatus, dbo.tblJobInstructions#1.ContractIDKey FROM dbo.tblJobInstructions#1 INNER JOIN dbo.tblSites ON dbo.tblJobInstructions#1.[Site Code] = dbo.tblSites.SiteCode INNER JOIN dbo.tblFeatures ON dbo.tblJobInstructions#1.[Feature Code] = dbo.tblFeatures.FeatureCode INNER JOIN dbo.tblJobCategory1 ON dbo.tblJobInstructions#1.Category1ID = dbo.tblJobCategory1.JobCategory1ID WHERE (dbo.tblJobInstructions#1.ContractIDKey = '16') AND (dbo.tblJobInstructions#1.JobStatus = '" + Replace(rsStatus__VarStatus, "'", "''") + "')"
rsStatus.CursorType = 0
rsStatus.CursorLocation = 2
rsStatus.LockType = 1
rsStatus.Open()

rsStatus_numRows = 0
%>

<%
If Request.QueryString("status")="y" Then

rsStatus.movefirst

DIM Datestring

Datestring = Date()
Datestring = Replace(Datestring, "/", "")
Response.Buffer = TRUE
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=" &Datestring& ".csv"
Response.CacheControl="no-cache"
Response.Write(line)
Response.End()
End if
%>

<a href="<%= Request.ServerVariables("SCRIPT_NAME") %>?status=y"><img src="../img/table/print_button.gif" width="86" height="27" border="0" align="bottom"></a>
 
emissions said:
If Request.QueryString("status")="y" Then

rsStatus.movefirst

You're not checking if there are any records before moving to the first one.

And response.write(line) - where do you define and fill the variable 'line' ?

I would also recommend using GetString to retrieve the records into the relevant CSV format...
e.g.:

A smile is worth a thousand kind words. So smile, it's easy! :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top