473,385 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Displaying the results of two MS Access tables using ASP

Hiya

I'm learning ASP using Access and Dreamweaver. I've just started
simple and I've tried to make the db show the results of just two
tables without doing anything clever! I have the following code:

<!--#include file="Connections/imaildata.asp" -->
<%
Dim rsData
Dim rsData_numRows

Set rsData = Server.CreateObject("ADODB.Recordset")
rsData.ActiveConnection = MM_imaildata_STRING
rsData.Source = "SELECT * FROM domain1_co_uk, domain2_com"
rsData.CursorType = 0
rsData.CursorLocation = 2
rsData.LockType = 1
rsData.Open()

rsData_numRows = 0
%>

And then in the body I have:

<%
while not rsData.EOF
Response.write rsData("FULLNAME")&"<br>"
rsData.MoveNext
Wend
%>

However, instead of getting a list of the fullname fields from both
tables I get strangely duplicated data from just one table, in the
form of:
edmund blackadder
edmund blackadder
percy
percy
baldrick
baldrick
kevin darling
kevin darling

etc

Any ideas why?

Cheers then!
Stu.
Nov 13 '05 #1
6 1878
"Stuart Clark" <st**********@Excite.com> wrote in message
news:c7**************************@posting.google.c om...
Hiya

I'm learning ASP using Access and Dreamweaver. I've just started
simple and I've tried to make the db show the results of just two
tables without doing anything clever! I have the following code:

<!--#include file="Connections/imaildata.asp" -->
<%
Dim rsData
Dim rsData_numRows

Set rsData = Server.CreateObject("ADODB.Recordset")
rsData.ActiveConnection = MM_imaildata_STRING
rsData.Source = "SELECT * FROM domain1_co_uk, domain2_com"
rsData.CursorType = 0
rsData.CursorLocation = 2
rsData.LockType = 1
rsData.Open()

rsData_numRows = 0
%>

And then in the body I have:

<%
while not rsData.EOF
Response.write rsData("FULLNAME")&"<br>"
rsData.MoveNext
Wend
%>

However, instead of getting a list of the fullname fields from both
tables I get strangely duplicated data from just one table, in the
form of:
edmund blackadder
edmund blackadder
percy
percy
baldrick
baldrick
kevin darling
kevin darling

etc

Any ideas why?

Cheers then!
Stu.

This isn't really the place to ask about ASP. Even if you use an mdb file
to store the data, you are not using Microsoft Access. In fact you may not
even have Access installed. If you do though, you could paste the query
below into the SQL view of a new query:

SELECT * FROM domain1_co_uk, domain2_com

and you will see the same result. ie the problem is not with ASP or Access
but in the SQL statement. I expect you need a join between the two tables
but you have not given any indication of the structure or the results you
expected.

Nov 13 '05 #2
Thanks for the advise! My apologies if I am posting in the wrong place -
I don't really know where else to try!

So if you don't mind answering this, what would be the correct SQL
statement in this scenareo?

All I want to do is display everything contained in two tables;

domain1_co_uk
domain2_com

Both tables have exactly the same structure, with the same fields/names
etc, just different information.

All I want it to do is list first one table, and then the other.

Cheers,
Stu.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3
"Stuart Clark" <st**********@excite.com> wrote in message
news:41**********************@news.newsgroups.ws.. .
Thanks for the advise! My apologies if I am posting in the wrong place -
I don't really know where else to try!

So if you don't mind answering this, what would be the correct SQL
statement in this scenareo?

All I want to do is display everything contained in two tables;

domain1_co_uk
domain2_com

Both tables have exactly the same structure, with the same fields/names
etc, just different information.

All I want it to do is list first one table, and then the other.


It sounds like you need a UNION query, e.g.

SELECT forename, surname FROM domain1_co_uk
UNION ALL
SELECT forename, surname FROM domain2_com;

You can also stick an "ORDER BY surname, forename" before the semi-colon if
you want both lists sorted together.

The SQL doesn't need to be on separate lines - I just split it to make it
easier to read.

Andrew
Nov 13 '05 #4
That's fantastic! Thanks for the advise! I shall go and try that now!

Thanks again!

Stu.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #5
Search in ACCESS Help for UNION query...

so long as the field names are the same they that will do what you want.
something like

SELECT * from domain1_co_uk
union
SELECT * from domain2_com
where....
order by....etc

HTH
Mal.
"Stuart Clark" <st**********@excite.com> wrote in message
news:41**********************@news.newsgroups.ws.. .
Thanks for the advise! My apologies if I am posting in the wrong place -
I don't really know where else to try!

So if you don't mind answering this, what would be the correct SQL
statement in this scenareo?

All I want to do is display everything contained in two tables;

domain1_co_uk
domain2_com

Both tables have exactly the same structure, with the same fields/names
etc, just different information.

All I want it to do is list first one table, and then the other.

Cheers,
Stu.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 13 '05 #6
Nearly had it!

I take it then that there is a limit to how long a SELECT statement is?
I nearly had it working. I gave up on the two pages communicating with a
cookie idea and put everything back into one page as I originally had
it. Used ADOX to get the table names, wrote them into a SELECT statement
which was stored as a variable, and then created a recordset using the
SELECT statement stored in the variable.

I think it may have worked, but there must be over a hundred tables in
the database, and I think the SELECT statement must have therefore been
too long as I had an error:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Query is too complex.
/imail/TMP3o63a5kj6l.asp, line 41
Back to the drawing board I suppose!

Thanks for all the help so far. I've not given up yet ;)

Cheers,
Stu.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Aladdin | last post by:
I have an MS Access form on which I have a listbox listing tables in that database. I want to be able to click on any of those tables and view its contents on the same form using subforms or any...
5
by: Robert | last post by:
Hello Accessors I have some reports created in Access that are very good for what they do. However, it seems to me that when you are displaying information you don't need to print out that a...
2
by: Chuck Reed | last post by:
I use ADO.Recordsets constantly to query data from external sources and append the results into tables in Access databases. A number of the queries I deal with bring back in excess of 50,000...
7
by: Joe | last post by:
I am using Access 2003 and are linking to an Oracle 9i ODBC datasource (using Oracle ODBC drivers). After linking the tables in Access, I inspect the data contained in the linked tables. For...
6
by: stephan.vanbeerschoten | last post by:
Hi All, I am relatively new to MS Access but am wel suited in general relational databases. I seem to be unable to accomplish the displaying of query results that return more then one line item....
7
by: smd | last post by:
Hello and thanks for taking the time to read this. I've looked all over the web and newsgroups and can't find a solution to my problem. I've posted this question to the Access 2000 group as well -...
4
by: Tim T | last post by:
Hi, I have a stored procedure executing a search and an asp.net page displaying the results in a datagrid. The datagrid has paging on it, I am using Visual Studio.NET and can't see any option...
0
by: dipper | last post by:
I have a dataset with several tables. Now i want to create different dataviews displaying results from some of the tables. I manage to create a view displaying 1 table, but how do i create a view...
3
by: Ken Fine | last post by:
This is a question that someone familiar with ASP.NET and ADO.NET DataSets and DataTables should be able to answer fairly easily. The basic question is how I can efficiently match data from one...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.