Forums

ASP

This topic is locked

Querying a recordset

Posted 22 Jan 2005 22:27:55
1
has voted
22 Jan 2005 22:27:55 Michael Behan posted:
Is it possible to query a recordset in an asp page? I've been experimenting to no avail, not sure if it's impossible or if I just dont know the syntax.
What I want is something like

< var name = createObject(adob.recordset);
name.source="SELECT * FROM [the recordset created earlier in the page] WHERE [whatever]";
>

hopefuly anyway.

(I'm using dreamweaver mx2004 asp javascript)

Thanks.

Replies

Replied 22 Jan 2005 23:29:49
22 Jan 2005 23:29:49 Chris Charlton replied:
Yes, you can use the <i>Advanced Recordset</i> dialog window to create SQL Variables (and define test values and run-time values) and generate the SQL code there, and click OK.

If you look at the code, you'll see what it checks for your passed variables, otherwise lays in a default value. Read up on <b>DW MX/MX2004: Controlling Recordset Defaults</b> - www.dmxzone.com/go?7072 . <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle> Hope that helps.
Replied 23 Jan 2005 21:36:39
23 Jan 2005 21:36:39 Michael Behan replied:
Thanks Chris but that's not really what I'm looking for.

After creating a recordset in the asp page I then want to make a new recordset that selects from the first one in the same way you would normally select from a table or a view.

i.e. the sql statement would be select * from recordset1 rather than select * from tbl_1

Thanks again
Replied 24 Jan 2005 10:47:11
24 Jan 2005 10:47:11 Vince Baker replied:
THis is possible, first create your recordset1 with the filtering value and then reference the filtering value from recordset1 in recordset2.

i.e.

(Recordset2)

Select *
from tbl_name
where your_id = varID

'Then define the variable in advanced view

Name Default Value RunTime Value
varID % recordset1.fields.item("your_id"

And recordset2 will be filtered on the value you select in recordset1.

Regards
Vince

DMX Talkzone Manager

Visit my home: www.chez-vince.com
(Now completely CSS based and bye bye to all tables!)

VBScript | ASP | HTML | CSS | SQL | Oracle | Hosting
Replied 24 Jan 2005 13:09:56
24 Jan 2005 13:09:56 Michael Behan replied:
Again this isn't what I'm trying to achieve. I don’t want to select from a table where something = a value from a previous recordset. I want to select from a recordset where something = a request variable. My problem is not in defining the variables but in selecting from a recordset. Ideally a stored procedure would create a view in the database and my recordset would select from this view, but not being able to create a view in a stored procedure I want to use a recordset instead.

Is this possible?
Replied 24 Sep 2008 18:58:14
24 Sep 2008 18:58:14 hunter Sinclair replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Again this isn't what I'm trying to achieve. I don’t want to select from a table where something = a value from a previous recordset. I want to select from a recordset where something = a request variable. My problem is not in defining the variables but in selecting from a recordset. Ideally a stored procedure would create a view in the database and my recordset would select from this view, but not being able to create a view in a stored procedure I want to use a recordset instead.

Is this possible?

<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Did you ever find a solution to this - I have been looking to do the same thing. My deal is I have an ASP page that I show lets say a dozen graphics on that are pulled from a database, each with different query parameters, but all from the same table. I want to do one SQL statement on the DB for the entire page that returns all the graphics and then make several queries against the returned Recordset or even Dictionary if I have to in order to reduce database hits on my server. Anyone have a soultion for this?

Reply to this topic