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

Records Affected problem

Status
Not open for further replies.

gpalmer711

IS-IT--Management
May 11, 2001
2,445
GB
I am having some problems with some ASP code, which was working fine before I went to bed last night. However it is now not working and I don't remember changing anything.

Code:
Dim objRS,objConn,strID,strProduct
Set objRS = Server.CreateObject("ADODB.Recordset")
set objConn = Server.CreateObject("ADODB.Connection")
					
mySQL = "SELECT * FROM products WHERE ProductID =" & Request.QueryString("product")
					
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("mvpdb") & "/faqs.mdb;Jet OLEDB:Database Password=<MYPASSWORD>;"
objRS.Open mySQL,objConn,3,3
					
Response.Write "<br>"
Response.write "<font face=""Arial""><h1 align=""center"">" & objRS("product_name") & "</h1></font>"
Response.Write "<p align=""center"">"
response.write "<img src=""logos/" & objRS("image") & """ alt=""" & objRS("product_name") & """>"
response.write "<br><br>"
					
'objRS.Close
'objConn.Close
					
mySQL = "SELECT * FROM sites WHERE product_ID=" & Request.QueryString("product")
					
'objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("mvpdb") & "/faqs.mdb;Jet OLEDB:Database Password=<MYPASSWORD>;"

set objRS = objConn.Execute(mySQL,intRecordsAffected)
					
if intRecordsAffected =< 0 Then 
Response.Write "We currently do not have any FAQs for this product, please try back again soon." & intRecordsAffected & mySQL
else

REST OF CODE HERE

The problem is with intRecordsAffected, even if there are more than 0 records returned then intRecordsAffected = 0

If I comment out the IF block and just leave the code that executes after the ELSE statement then the page displays as expected.

Anyone see any problems with this?

Greg Palmer
Freeware Utilities for Windows Administrators.
 
You should probably have something like:

intRecordsAffected = objRS.RecordCount

after you have executed the query.

Good luck!
 
emozley wrote:
>You should probably have something like:
>[tt]intRecordsAffected = objRS.RecordCount[/tt]
>after you have executed the query.

I guess it is so off that the op should ignore that part. outparam intRecordsAffected and RecordCount are ideas so different from one another to warrant that kind of equation.
 
Hi Guys,

This is me getting it totally confused. I don't use ASP that often and was refering to a site I did some time ago that used both Records Affected and RecordCount.

Thanks for all your help.

Still strange that it worked initially though.

Greg Palmer
Freeware Utilities for Windows Administrators.
 
Since I engaged in a contro, I might not in the best position to advise. Unfortunately, I still do not see other db-ists to step in for additional help. So bear with these notes.

[1]
>[tt]mySQL = "SELECT * FROM products WHERE ProductID =" & Request.QueryString("product")[/tt]
[tt]mySQL = "SELECT * FROM products WHERE ProductID =[COLOR=red yellow]'[/color]" & Request.QueryString("product") [COLOR=red yellow]& "'"[/color][/tt]

[2] Since your query is not an action query, so I don't think you should use RecordsAffected as a proxy to record count _at all at all_. You would get back probably an empty type at that place if the irecordaffected is not initialized and hence the conditional would be evaluated to true. Make sure there is no position number assigned to it before the .execute line; or simply put it to null. With null assigned before execute line, for non-action query, you'll probably still get back null and the conditional will be evaluated to false due to offball null behaviour and then you'll get to the else part.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top