Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Dynamic VS Absolute SQL

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-10-02 : 00:26:45
Rob writes "Hello there,

Just wondering if the ASP gods would smile down on this code and make it work.

When I look in the database and get the productID and sessionID and type it in the query it works. When it is generated dynamically it doesn't work yes both SQL statements look identical when printed out.

Am I missing something in this nested query structure? I have already sacrificed many mice to the ASP gods but to no avail.

This is a query within a query. First I get * from catalogue, then use productID to query the shoppingcart table for units...


Here's the offending code:

Why does this work:

Set existingUnits = connect.execute("SELECT units from shoppingcart WHERE productID = '101' AND sessionID='32192342'"


And this does not:


SQL2 = "SELECT units FROM shoppingcart " & _
"WHERE productID = '" & recordSet.Fields("productID") & _
"' AND sessionID = '" & sessionID & "'"

Set existingUnits = connect.execute(SQL2)

SQL2 generates the same string as I typed in absolutely above.


I get an error when I try to access existingUnits.Fields("units") saying it is either EOF or BOF or record has been deleted.

Any suggestions?"
   

- Advertisement -