Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8207417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:59:15+00:00 2026-06-07T08:59:15+00:00

Here is a sample access query which I have(query ref/name – abovequery) select column_date,

  • 0

Here is a sample access query which I have(query ref/name – abovequery)

select column_date, sum(field1), sum(field2) from table
group by column_date
union all
select 'Total' as column_date, sum(field1), sum(field2) from table

When I try to access the SQL query in browser using below code in asp, it displays only heading.

<html>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.open "odbcdatasourcename"
set rs = Server.CreateObject("ADODB.recordset")
sql="SELECT * from abovequery"
rs.Open sql, conn
%>
<table border="1" width="100%">
<tr>
<%for each x in rs.Fields
response.write("<th>" & x.name & "</th>")
next%>
</tr>
<%do until rs.EOF%>
<tr>
<%for each x in rs.Fields%>
   <td><%Response.Write(x.value)%></td>
<%next
rs.MoveNext%>
</tr>
<%loop
rs.close
conn.close
%>
</table>
</body>
</html>

Please note when I copy the output of above query into a table and use the same asp code, it works fine. So obviously it is an issue of executing “UNION” query in asp. I wonder if there is any solution for this. The same problem happens when I try to execute crosstab query also.

New: This is what I tried now

  • but its last row with total is not correctly aligned along with the other main data rows.

Here is a sample access query which I have created now

1st query – query1

select column_date, sum(field1), sum(field2) from table
group by column_date

2nd query – query2

select 'Total' as column_date, sum(field1), sum(field2) from table

asp code

<html>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.open "odbcdatasourcename"
set rs = Server.CreateObject("ADODB.recordset")
sql="SELECT * from query1"
rs.Open sql, conn
%>
<table border="1" width="100%">
<tr>
<%for each x in rs.Fields
response.write("<th>" & x.name & "</th>")
next%>
</tr>
<%do until rs.EOF%>
<tr>
<%for each x in rs.Fields%>
   <td><%Response.Write(x.value)%></td>
<%next
rs.MoveNext%>
</tr>
<%loop
rs.close
conn.close
%>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.open "odbcdatasourcename"
set rs = Server.CreateObject("ADODB.recordset")
sql="SELECT * from query2"
rs.Open sql, conn
%>
<table border="1" width="100%">

<%for each x in rs.Fields%>
   <td><%Response.Write(x.value)%></td>
<%next
rs.MoveNext%>
</tr>
<%loop
rs.close
conn.close
%>
</table>
</body>
</html>

This is my third try to fix alignment problem

<html>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.open "odbcdatasourcename"
set rs = Server.CreateObject("ADODB.recordset")
sql="SELECT * from query1"
rs.Open sql, conn
%>
<table border="1" width="100%">
<tr>
<%for each x in rs.Fields
response.write("<th>" & x.name & "</th>")
next%>
</tr>
<%do until rs.EOF%>
<tr>
<%for each x in rs.Fields%>
   <td><%Response.Write(x.value)%></td>
<%next
rs.MoveNext%>
</tr>

<%
set rs = Server.CreateObject("ADODB.recordset")
sql="SELECT * from query2"
rs.Open sql, conn
%>
<%for each x in rs.Fields%>
<td><%Response.Write(x.value)%></td>
<%next
rs.MoveNext%>
</tr>
<%loop
rs.close
conn.close
%>
</table>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:59:16+00:00Added an answer on June 7, 2026 at 8:59 am

    Your description sounds like the recordset contains no records. Confirm this point.

    <html>
    <body>
    <%
    set conn=Server.CreateObject("ADODB.Connection")
    conn.open "odbcdatasourcename"
    set rs = Server.CreateObject("ADODB.recordset")
    sql="SELECT * from abovequery"
    rs.Open sql, conn, 3 ' adOpenStatic '
    Response.Write("RecordCount: " & rs.RecordCount)
    rs.close
    conn.close
    %>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the sample data for test table I have [childId] [parentId] [present] 1
I have a problem with a relatively simple query and the execution plan Access
I've got a query here which does what it is supposed to but I'm
I have a bunch of notes in Evernote which I would like to access
Here is a sample data set ----------------------------------------------------------------------------------------- id nameid name score diff include quantity
I have a simple ajax query to a file which basically returns in JSON
I have a query which uses an array of tables (stored as a string
I would like to access class variables with for loop, here is my simple
Here is sample data <table class=sparql border=1> <tr> <th>abstract</th></tr> <tr> <td> Cologne is Germany&#39;s
here the sample case.. i want to display banner randomly by percentage based on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.