473,543 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3938
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).Na me & "</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.Fiel ds.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).Na me
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(NameInde x,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
2291
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 fine I think) that will say "I'm sorry but the data you requested cannot be found" or something along those lines.... This code is on an archive...
25
10177
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 data in each record, which includes the ID of the father and the mother (who also have records in the table). One record per form. I have a Tab...
22
2843
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 a table and add the index value and a value/s from each recordset in turn, into a temporary table, which I used to create a report. I created this...
13
3444
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 query: QryICTMassDistribution3) , I then use a form and the code below to create a new record in the corrispondence table to show what...
1
5899
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 items. I have a VB6 application that is tied into this database using an ADODB.Connection and uses two ADODB.Recordsets: rsEmployees and rsItems. I...
5
6422
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 solution: 1. I am not allowed to use ODBC 2. I have to use ADO 3. I am not allowed to use Linked tables
36
4422
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 dataview with a count = 0. Can someone explain why and how I might work around this problem? Here is the code for my function: Public Shared...
2
3498
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. I tried: Public Sub OpenDefaults() Dim db As dao.Database Dim globalRst As dao.Recordset Set db = CurrentDb() Set globalRst =...
11
2718
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. I wish to evaluate one field in the record and depending on the value in that field I wish to change the colour of the line in the table. As
0
7729
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7332
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7677
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5258
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4884
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3385
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3386
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1809
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
952
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.