Solved

Query a Recordset

Posted on 2011-09-21
6
263 Views
Last Modified: 2012-08-13
Hi All,

If I query my SQL Database: "Select ProductCode from ShoppingCart Where SessionID = x" and place the results into a recordset (rs) - everything works fine.

What I want to do is now say:
If Product123 is listed in rs.fields.productcode Response.Write("xxx") ELSE Response.Write("yyy")

Can this be easily achieved?
0
Comment
Question by:powellt77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 28

Expert Comment

by:sammySeltzer
ID: 36577405
Do you mean:

SQL = "Select ProductCode from ShoppingCart Where SessionID = x" 

set rs=conn.execute(SQL)

DO UNTIL RS.EOF
ProdCode = RS("ProductCode")

If ProdCode = 'Product123' Then
   Response.Write "xxx"
Else
  Response.Write "yyy"
End If
RS.MoveNext
Loop

Open in new window

0
 
LVL 15

Expert Comment

by:Eyal
ID: 36578336
I would not loop thru the rs. there is a simpler way.

http://www.w3schools.com/ado/prop_rs_filter.asp
0
 

Author Comment

by:powellt77
ID: 36583182
Thank You both - Eval, the filter option looks like it could work.
I'm trying not to hammer the server, but understand it'll need to do some work.

I'm new to the ADO Filter property - would you be kind enough to show roughly how I'd implement it?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Accepted Solution

by:
Eyal earned 300 total points
ID: 36594248
something like that

Dim Value
Value = "Product123"

SQL = "Select ProductCode from ShoppingCart Where SessionID = x" 

set rs=conn.execute(SQL)

rs.Filter = "ProductCode = '"&Value &"'" 

if not (rs.EOF or rs.BOF)
 Response.Write "xxx"
Else
  Response.Write "yyy"
End If

Open in new window

0
 
LVL 28

Expert Comment

by:sammySeltzer
ID: 36594289
WOW!
This is simpler and more elegant?
0
 
LVL 15

Expert Comment

by:Eyal
ID: 36594420
powellt77: I didn't mentioned it but if you can query the database again it will be the fastest solution

sammySeltzer:
first your code moves thru out all the records and print for each record the xxx/yyy. I assume this is not what is needed.
second, do you think your code is better from what Microsoft wrote inside the ADO library for the Recordset object?

0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question