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.
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
>>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?
Can you tell us what is the "issue" or am I missing something?
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.
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..
also post you query here for us to review..
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.
ASKER
Here is the query:
SELECT Hyundai_Career_Job.JobTitl e as JobTitle, Hyundai_Career_Job.PublicD ate, Hyundai_Career_Job.JobID as JobID, Hyundai_Career_Job.Educati on as Education, Hyundai_Career_Job.JobType as JobType, Hyundai_Career_Job.Experie nce as Experience, Hyundai_Career_Dealer.Deal erID as DealerID, Hyundai_Career_Dealer.Name as DealerName, Hyundai_Career_Job.RemoveD ate as RemoveDate, Hyundai_Career_Dealer.City as DealerCity, Hyundai_Career_Dealer.Stat e as DealerState, Hyundai_Career_Dealer.Zip as DealerZip, Hyundai_Career_Dealer.Stat us as Status FROM Hyundai_Career_Job JOIN Hyundai_Career_Dealer on Hyundai_Career_Dealer.Deal erID = Hyundai_Career_Job.DealerI D WHERE Hyundai_Career_Job.RemoveD ate IS NOT NULL AND Hyundai_Career_Job.DealerI D=37 ORDER BY Hyundai_Career_Job.PublicD ate DESC
SELECT Hyundai_Career_Job.JobTitl
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?
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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!"
"I knew it was something simple and stupid. I had one in there that i didn't realize was still active. Thanks!"
strSQL = "SELECT Hyundai_Career_Job.JobTitl
remove quotes ' from DealerId