473,322 Members | 1,911 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,322 software developers and data experts.

get recordset value outside the table

I need to display data like this:

CompanyName1

Company | Date| Transactions Count -- headers
CompanyName1 | Date| 1 -- data
CompanyName2 | Date| 5 -- data
CompanyName3 | Date| 2 -- data
CompanyName4 | Date| 7 -- data

COMPANYNAME1 should be outside the table
<table>
<tr>
<%
For each fld in objRS.Fields
Response.Write("<td>" & fld.Name & "</td>")
Next
objRS.MoveFirst
%>
</tr>
<%
Do until objRS.EOF
%>
<tr>
<%
For each fld in objRS.Fields
Response.Write("<td>" & fld & "</td>")
Next
objRS.MoveNext
%>
</tr>
</table>

Help please!
Jul 19 '05 #1
9 3930
Hamster wrote:
I need to display data like this:

CompanyName1

Company | Date| Transactions Count -- headers
CompanyName1 | Date| 1 -- data
CompanyName2 | Date| 5 -- data
CompanyName3 | Date| 2 -- data
CompanyName4 | Date| 7 -- data

COMPANYNAME1 should be outside the table
<table>
<tr>
<%
For each fld in objRS.Fields
Response.Write("<td>" & fld.Name & "</td>")
Next
objRS.MoveFirst
%>
</tr>
<%
Do until objRS.EOF
%>
<tr>
<%
For each fld in objRS.Fields
Response.Write("<td>" & fld & "</td>")
Next
objRS.MoveNext
%>
</tr>
</table>

Help please!


Please rephrase your question.

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #2
I have table with headers and data populated dynamically.

<table border="1" cellpadding="0" cellspacing="0">
<tr>
<%
For each fld in objRS.Fields
Response.Write("<td>" & fld.Name & "</td>")
Next
objRS.MoveFirst
%>
</tr>
<%
Do until objRS.EOF
%>
<tr>
<%
For each fld in objRS.Fields
Response.Write("<td>" & fld & "</td>")
Next
objRS.MoveNext
%>
</tr>
<%
Loop
%>
</table>

What I need:
1)C1 to be the title of the table, it should be outside <table> tag
2)Company column to be hidden (I know the column to be hidden, it's the
one that has ~T~ at the end)

C1

Company | Date | Transaction
C1 12/12/2003 Transaction1
C1 12/13/2003 Transaction2
C1 12/14/2003 Transaction3

Thanks.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #3
Katya Kotova wrote:

What I need:
1)C1 to be the title of the table, it should be outside <table> tag
That's easy enough. It looks like every record in the recordset has "C1" in
the first field. So just read the value of the first field and write it to
the response before starting the table.

2)Company column to be hidden (I know the column to be hidden, it's
the one that has ~T~ at the end)


Sorry, but this means nothing to me. I'm not looking over your shoulder. I
don't know where you are seeing this "~T~".

I'm assuming Company is the first field in the recordset? Why create the
column in the table if you want it to be hidden?
<%
'open the recordset - use rs, not objRS (less typing)
Response.write rs(0)
%>
<table border="1" cellpadding="0" cellspacing="0">
<%
Dim i
response.write "<tr>"
for i = 1 to rs.Fields.count - 1
Response.Write("<td>" & rs.Fields(i).Name & "</td>")
next
response.write "</tr>"
'no need to do a MoveFirst here
Do until rs.EOF
response.write "<tr>"
for i = 1 to rs.Fields.count - 1
Response.Write("<td>" & rs(i) & "</td>")
next
response.write "</tr>"
loop
response.write "</table>"
%>

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #4
Thanks.
I would like to do this for every column that has, for example,
Right(fld.Name, 4) = "name", not only for the first column.

I am creating a universal component that I can use for a lot of web
reports.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #5
Katya Kotova wrote:
Thanks.
I would like to do this for every column that has, for example,
Right(fld.Name, 4) = "name", not only for the first column.

I am creating a universal component that I can use for a lot of web
reports.

Please provide a more detailed example that thoroughly explains what you
mean by "do this".

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #6
I would like to take first field value from column that has "name" at
the end (it can be 2nd, 3rd, 11th column)and to make this value to be a
title of this table.

Smith & Co

ID | EmployeeID | Contact | CompanyName |
12 | 12345 | Smith | Smith & Co
13 | 12346 | Gardner | Smith & Co

Thanks for your patience.
I am trying to create component that I can use for a number of web
reports. It should determine the column name with "name" at the end, and
if it exists it should create a title from it's first value and hide
this particular column.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 19 '05 #7
Katya Kotova wrote:
I would like to take first field value from column that has "name" at
the end (it can be 2nd, 3rd, 11th column)and to make this value to be
a title of this table.

Smith & Co

ID | EmployeeID | Contact | CompanyName |
12 | 12345 | Smith | Smith & Co
13 | 12346 | Gardner | Smith & Co

Thanks for your patience.
I am trying to create component that I can use for a number of web
reports. It should determine the column name with "name" at the end,
and if it exists it should create a title from it's first value and
hide this particular column.

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


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #8
Katya Kotova wrote:
I would like to take first field value from column that has "name" at
the end (it can be 2nd, 3rd, 11th column)and to make this value to be
a title of this table.

Smith & Co

ID | EmployeeID | Contact | CompanyName |
12 | 12345 | Smith | Smith & Co
13 | 12346 | Gardner | Smith & Co

Thanks for your patience.
I am trying to create component that I can use for a number of web
reports. It should determine the column name with "name" at the end,
and if it exists it should create a title from it's first value and
hide this particular column.


Errm, OK.

I assume you will have some method to make sure that only one field ends
with the word "name" given that you don't know either the names of the
fields or the order in which they will be retrieved ...?

Enough with this inefficient recordset looping. Time to use some arrays:

'open the recordset, then
Dim arData. arNames(), i, j, NameIndex
redim arNames(rs.Fields.Count - 1)
for i = 0 to rs.Fields.Count - 1
if lcase(Right(rs.Fields(i).Name,4)) = "name" then NameIndex = i
arNames(i) = rs.Fields(i).Name
next
if not rs.EOF then arData = rs.GetRows
rs.close: set rs=nothing
'close and destroy the connection as well

'arData will not be an array if no records were returned
If IsArray(arData) then

'write the value contained in the column identified by NameIndex
'from the first row of data in arData
Response.Write arData(NameIndex,0) & "<BR>"

'Build the table using all columns except the one identified by
'NameIndex

Response.Write "<table><tr>"
for i = 0 to ubound(arNames)
if i <> NameIndex then
Response.Write "<th>"
Response.Write arNames(i)
Response.Write "</th>"
End If
next
Response.Write "</tr>"

for i = 0 to Ubound(arData,2)
Response.Write "<tr>"
for j = 0 to Ubound(arData,1)
If j <> NameIndex then
Response.Write "<td>"
Response.Write arData(j,i)
Response.Write "</td>"
End if
next
Response.Write "</tr>"
next
Response.Write "</table>"

Else
'handle the situation where no records were returned
End if

HTH,
Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #9
thanks a lot, Bob


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

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

Similar topics

8
by: dmiller23462 | last post by:
My brain is nuked....Can anybody tell me right off the bat what is wrong with this code? Along with any glaring errors, please let me know the syntax to display a message (Response.Write would be...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
22
by: Gerry Abbott | last post by:
Hi all, I having some confusing effects with recordsets in a recent project. I created several recordsets, each set with the same number of records, and related with an index value. I create...
13
by: Jan | last post by:
Hi I have a database that I use to keep track of the sales promotions that we send to companies. I normally send a mailing based on a subset of the companies in the database (found using the...
1
by: Ray Holtz | last post by:
I have a database in Access 2003 (Access2000 file format). There are two tables that are being used: Employees and Items. It is linked by the Employee field so that one employee can have many...
5
by: Fabrice | last post by:
Hello everybody, I'm working with Access 2002. I have to import Data from a Foxpro table that contains 25000 records in an Access table. I have a couple of restrictions placed on me for the...
36
by: kjvt | last post by:
Based on a prior posting, I've written a function to convert a recordset to a dataview. The first call to the function for a given recordset works perfectly, but the second call always returns a...
2
by: Jim M | last post by:
I rarely deal with recordsets directly with code, since I usually use Access queries, so be patient with this question. I want to open a recordset with various default variables used by my program....
11
by: altreed | last post by:
Hi, I am new to ASP, HTML and iis. I have my asp code working so that I can retrieve my desired record from the database. I can place the data on the screen in table form. All works fine. ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.