Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 17th, 2005, 04:20 PM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default how query 2 tables in asp

i wonder how i can query 2 diffrent tables with int <script > </script > in asp.(for example two select statments for 2 diffrent tables. I be happy if some one help me here. thanks

 
Old March 17th, 2005, 05:57 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Like this?
strSQL1 = "SELECT * FROM table1"

strSQL2 = "SELECT * FROM table2"

 
Old March 18th, 2005, 05:31 AM
Authorized User
 
Join Date: Dec 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to shankhan Send a message via Yahoo to shankhan
Default

let me tell u bit details of above queries. execute 2 quries using 2 different record set.
strSQL1 = "SELECT emp_no, e_name from table1"
strSQL2 = "SELECT dept_no, d_name from table2"
set rs_table1 = con.execute(strSQL1)
set rs_table2 = conn.execute(strSQL2)
'now you can display the output of both queries by calling their record set. like
response.write rs_table1(0)
response.write rs_table2(0)
response.write rs_table1(1)
response.write rs_table2(1)
' these r index number of those record sets. u also can call values by using column name
response.write rs_table1(emp_no)
response.write rs_table2(dept_no)
response.write rs_table1(e_name)
response.write rs_table2(d_name)
i hope u can find some help from this example.
Zee


 
Old March 18th, 2005, 01:06 PM
Authorized User
 
Join Date: Mar 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

dear u can even fill these tables in a sigle dataset and retrieve them

SqlDataAdapter da = new SqlDataAdapter();
DataSEt= new DataSet()

da.SelectCommand=str1;
da.Fill(ds);
da.SelectCommand=str2;
da.Fill(ds);

//now u can retrieve
ds.Tables[0]................
ds.Tables[1]......................


 
Old March 19th, 2005, 06:52 AM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by shankhan
 let me tell u bit details of above queries. execute 2 quries using 2 different record set.
strSQL1 = "SELECT emp_no, e_name from table1"
strSQL2 = "SELECT dept_no, d_name from table2"
set rs_table1 = con.execute(strSQL1)
set rs_table2 = conn.execute(strSQL2)
'now you can display the output of both queries by calling their record set. like
response.write rs_table1(0)
response.write rs_table2(0)
response.write rs_table1(1)
response.write rs_table2(1)
' these r index number of those record sets. u also can call values by using column name
response.write rs_table1(emp_no)
response.write rs_table2(dept_no)
response.write rs_table1(e_name)
response.write rs_table2(d_name)
i hope u can find some help from this example.
Zee


Thank u for u reply. how i can do the same for dirrent value passed to this page. What i mean for each diffrent value passed to this page it runs similer block of code but for diffrent tables. I mean kind of if statments. I be happy if u show me some code. thanks

 
Old March 19th, 2005, 12:24 PM
Authorized User
 
Join Date: Dec 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to shankhan Send a message via Yahoo to shankhan
Default

Quote:
quote:Originally posted by method
 
Quote:
quote:Originally posted by shankhan
Quote:
 let me tell u bit details of above queries. execute 2 quries using 2 different record set.
strSQL1 = "SELECT emp_no, e_name from table1"
strSQL2 = "SELECT dept_no, d_name from table2"
set rs_table1 = con.execute(strSQL1)
set rs_table2 = conn.execute(strSQL2)
'now you can display the output of both queries by calling their record set. like
response.write rs_table1(0)
response.write rs_table2(0)
response.write rs_table1(1)
response.write rs_table2(1)
' these r index number of those record sets. u also can call values by using column name
response.write rs_table1(emp_no)
response.write rs_table2(dept_no)
response.write rs_table1(e_name)
response.write rs_table2(d_name)
i hope u can find some help from this example.
Zee


Thank u for u reply. how i can do the same for dirrent value passed to this page. What i mean for each diffrent value passed to this page it runs similer block of code but for diffrent tables. I mean kind of if statments. I be happy if u show me some code. thanks

if rs_table1(emp_no) = 1 then
   e_no = "one"
elseif rs_table1(emp_no) = 2 then
   e_no = "two"
else
   e_no = "none"
end if
response.write e_no

i hope this is the answer of ur question.

Zee






Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying query from three tables slims07 .NET Framework 2.0 8 April 2nd, 2008 10:47 AM
help with two linked tables query footohi Access 2 August 25th, 2005 10:25 AM
how to query 2 tables in asp.net method ASP.NET 1.0 and 1.1 Basics 3 March 18th, 2005 04:35 PM
How to Merge Tables into one query sorcerer Access 5 March 11th, 2005 04:19 AM
two tables, one query, getting the latest for each eln MySQL 2 November 17th, 2003 11:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.