I.T. Discussion Community!
-Collapse +Expand
ASP Classic
Search ASP Classic Group:

Advanced
-Collapse +Expand ASP Classic Store

Prestwood eMagazine

June Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyASP Classic Coding BoardASP Classic - Handling Data Topic   Print This     

Viewing info selected from a table

Viewing info selected from a table in ASP Classic - Handling Data topic (part of our ASP Classic Coding group).

Quick Search: Viewing   selected   Viewing info   Viewing info selected  
aka51
MD
I am selecting info from an access table. the constraints for the select table are coming form another form so the information selected is never the same. Is it possible to write only the records that are selected in one command instead of writing each record individually like
 
response.write rs("name")
response.write rs("age")
Peace love and happiness
 Posted 16 years ago (Thread Starter)
Comment Quote
About aka51 -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #9566, 5 replies
Thread Started 5/13/2003 5:00:00 AM
View Counter=3443
Location=MD  
Joined=17 years ago   MB Posts=25  
jdschram
MN
im not sure what you meant by "constraints for the select table are coming form another form so the information selected is never the same"

Does this mean you are dynamically building the SELECT part of your SQL statement?

Select id,name from table
Select name from table

Or is it just selecting different recordsets?

Select name from table where name = 'me'
Select name from table where name = 'you'

Well both are possible, so just post back with any further information/questions and I'll try to help
 Posted 16 years ago
Comment Quote
About jdschram -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #9567 (Level 1.1)  Reply to 9566
Thread Started 5/13/2003 6:41:00 AM
View Counter=2
Location=MN  
Joined=18 years ago   MB Posts=259  
jdschram
MN
oh...are you using ASP or ASP.net?
 Posted 16 years ago
Comment Quote
About jdschram -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #9568 (Level 1.2)  Reply to 9566
Reply Posted 5/13/2003 6:42:00 AM
Location=MN  
Joined=18 years ago   MB Posts=259  
jdschram
MN
well..here is one issue...

rsmail("Action"),rsmail("can") and rsmail("emp_name") may not be in your sql query...
If you always want those three to be shown, your sql will need to be
Sql = "SELECT action,can,emp_name,"& request.form("SELECT") & _
" FROM "& request.form("DATABASE") & _
" where "& request.form("WHERE_FIELD") &" = '"& strwhere &"';"
set rsmail = Server.CreateObjec("ADODB.Recordset")
An easy and good way to debug your sql is to do a this right after you initialize the sql variable.
response.write sql
response.end
then copy/paste the sql you gerated into query analyzer/ms access and run it against the database.

I'm pretty sure I can help you get this running, i'm still a little confused. IF you want the select statement generated dynamically (like you have it) you cannot hardcode the RSMAIL column names (also like you are doing) without a guarentee that it will not break. So if you have more questions, or a site where i can look at what you are inputting and expecting back, please post it Big Grin!

*** one more note...you dont need to use the do while loop...or the if not rsmail.eof...it can be simplified to:
while not rsmail.eof
rsmail.movenext
wend
 Posted 16 years ago
Comment Quote
About jdschram -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #9573 (Level 1.3)  Reply to 9566
Reply Posted 5/13/2003 11:30:00 AM
Location=MN  
Joined=18 years ago   MB Posts=259  
aka51
MD

I am using ASP and this is the code I am using


<%
dim rsmail, sql

Sql = "SELECT "& request.form("SELECT") &" FROM "& request.form("DATABASE") &" where "& request.form("WHERE_FIELD") &" = '"& strwhere &"';"


set rsmail = Server.CreateObject("ADODB.Recordset")

rsmail.Open sql, db
if not rsmail.EOF then
do while not rsmail.EOF
%>

<% Response.Write rsmail("Action") %>


<% Response.Write rsmail("can") %>


<% Response.Write rsmail("emp_name") %>


<%
rsmail.MoveNext
loop
end if
%> However I will recieve anerror if I try to write the info to the screen as each select statement will select different things from the database so if one of the recordset (rsmail) was not selected it will cause an error.
Is there a way to write it without specificing which recordset
Peace love and happiness
 Posted 16 years ago (Thread Starter)
Comment Quote
About aka51 -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #9569 (Level 1.4)  Reply to 9566
Reply Posted 5/13/2003 7:03:00 AM
Location=MD  
Joined=17 years ago   MB Posts=25  
Most Recent Post
aka51
MD
I would love to have you look at the site but it is on an intranet, so public access is not possible.
But you do have the jist of the situation. The SQL statement is being generated dynamically, so I know that I can't hradcode rsmail as it will change with every run of the SQL statement, so I need to know how to get the info that was selected from the databse to be written out.
Peace love and happiness
 Posted 16 years ago (Thread Starter)
Comment Quote
About aka51 -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.

Post ID #9575 (Level 1.5)  Reply to 9566
Reply Posted 5/13/2003 11:40:00 AM
Location=MD  
Joined=17 years ago   MB Posts=25  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1194A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #9566 Counter
3443
Since 4/2/2008
Follow PrestwoodBoards on: 


©1995-2019 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech