Link to home
Start Free TrialLog in
Avatar of goware
goware

asked on

Recordset issues in classic ASP

I am trying to run a join SQL statement from within a classic ASP page to display results in the recordset. I am using the code attached to this question in multiple pages on my site with no problems. I have begun to believe that it's an issue with my SQL statement yet when I put the statement into the Query window in SQL Server Manager Express, it works fine and pulls the exact data it should. This is, of course, very frustrating and I'm sure it's some minor thing I am overlooking.

A few things to note:
1. the "WHERE" statement for dealerid is filled in with a session variable. I hardcoded it into the statement for testing purposes but I know that the session variable populates correctly (based on response.write output)
2. if i put in a response.write after the NOT rs.EOF, I get nothing. If I take out the "WHERE DealerID =" from the SQL statement, it works fine
3. PerPage is already defined
2.
Set rs = Server.CreateObject("ADODB.recordset")
rs.CursorLocation = adUseServer
 
strSQL = "SELECT Hyundai_Career_Job.JobTitle as JobTitle, Hyundai_Career_Job.PublicDate, Hyundai_Career_Job.JobID as JobID, Hyundai_Career_Job.Education as Education, Hyundai_Career_Job.JobType as JobType, Hyundai_Career_Job.Experience as Experience, Hyundai_Career_Dealer.DealerID as DealerID, Hyundai_Career_Dealer.Name as DealerName, Hyundai_Career_Job.RemoveDate as RemoveDate, Hyundai_Career_Dealer.City as DealerCity, Hyundai_Career_Dealer.State as DealerState, Hyundai_Career_Dealer.Zip as DealerZip, Hyundai_Career_Dealer.Status as Status FROM Hyundai_Career_Job JOIN Hyundai_Career_Dealer on Hyundai_Career_Dealer.DealerID = Hyundai_Career_Job.DealerID WHERE Hyundai_Career_Job.RemoveDate IS NOT NULL AND Hyundai_Career_Dealer.DealerID = '37' ORDER BY Hyundai_Career_Job.PublicDate DESC"
 
rs.Open strSQL, conn, adOpenStatic, adLockOptimistic			
			
if NOT rs.EOF then
			
		rs.AbsolutePage = PageNum 
 
        	x = 0 
       		while x < PerPage and not rs.eof

Open in new window

Avatar of neeraj523
neeraj523
Flag of India image

try this

strSQL = "SELECT Hyundai_Career_Job.JobTitle as JobTitle, Hyundai_Career_Job.PublicDate, Hyundai_Career_Job.JobID as JobID, Hyundai_Career_Job.Education as Education, Hyundai_Career_Job.JobType as JobType, Hyundai_Career_Job.Experience as Experience, Hyundai_Career_Dealer.DealerID as DealerID, Hyundai_Career_Dealer.Name as DealerName, Hyundai_Career_Job.RemoveDate as RemoveDate, Hyundai_Career_Dealer.City as DealerCity, Hyundai_Career_Dealer.State as DealerState, Hyundai_Career_Dealer.Zip as DealerZip, Hyundai_Career_Dealer.Status as Status FROM Hyundai_Career_Job JOIN Hyundai_Career_Dealer on Hyundai_Career_Dealer.DealerID = Hyundai_Career_Job.DealerID WHERE Hyundai_Career_Job.RemoveDate IS NOT NULL AND Hyundai_Career_Dealer.DealerID=37 ORDER BY Hyundai_Career_Job.PublicDate DESC"

remove quotes ' from DealerId
Avatar of Anthony Perkins
>>I have begun to believe that it's an issue with my SQL statement<<
Can you tell us what is the "issue" or am I missing something?
Avatar of goware
goware

ASKER

Sorry, i guess i wasn't explicit enough in my original question. The aforementioned SQL statement produces no data when run from the ASP page.

As for removing the quotes from DealerID, that does not help either.
can you print the sql statement before execution and the copy paste same query in query analyser and see what happens

also post you query here for us to review..
Avatar of goware

ASKER

I have already used a response.write to output the query string (using the session variable as the dealerid) and then copy-pasted the SQL statement into the query window. It returns the data fine in the query window but, as indicated in the root of this problem, nothing in the asp page.
Avatar of goware

ASKER

Here is the query:

SELECT Hyundai_Career_Job.JobTitle as JobTitle, Hyundai_Career_Job.PublicDate, Hyundai_Career_Job.JobID as JobID, Hyundai_Career_Job.Education as Education, Hyundai_Career_Job.JobType as JobType, Hyundai_Career_Job.Experience as Experience, Hyundai_Career_Dealer.DealerID as DealerID, Hyundai_Career_Dealer.Name as DealerName, Hyundai_Career_Job.RemoveDate as RemoveDate, Hyundai_Career_Dealer.City as DealerCity, Hyundai_Career_Dealer.State as DealerState, Hyundai_Career_Dealer.Zip as DealerZip, Hyundai_Career_Dealer.Status as Status FROM Hyundai_Career_Job JOIN Hyundai_Career_Dealer on Hyundai_Career_Dealer.DealerID = Hyundai_Career_Job.DealerID WHERE Hyundai_Career_Job.RemoveDate IS NOT NULL AND Hyundai_Career_Job.DealerID=37 ORDER BY Hyundai_Career_Job.PublicDate DESC
can you please change:
         
if NOT rs.EOF then

into:
         
if NOT (rs.EOF and rs.BOF) then

also, can you make 200% sure that you are connected to the correct database?
It seems the enclosed asp is not complete

anyway, you can try using a must correct sql, like "select 1 from sysobjects"
and test is it the db error, or the asp program error.

cheers.
Response.Write "Count: " & rs.RecordCount
can u check the output of above ???
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of goware

ASKER

I knew it was something simple and stupid. I had one in there that i didn't realize was still active. Thanks!

I am wondering if this issue was resolved and solution accepted is really the answer ??
Here is the comment from the author:
"I knew it was something simple and stupid. I had one in there that i didn't realize was still active. Thanks!"