Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: how to change Header and format cell when use RS.GetString


Message #1 by Ping Li <pli@l...> on Tue, 11 Dec 2001 11:52:19 -0600
Hello,All,



I was using GetString to create data output table. But the results look ugly

because it returned the original header name and no $ dollar sign when it's

needed. Could anybody help me with this format? Thanks a lot. Ping



Following are the codes:



if not RS.eof then

  response.write "<table border=1><tr>"

  'Header row

  for each oHeader in RS.Fields

    response.write "<th>" & oHeader.name & "</th>"

    next

  response.write "</tr> <tr><td align=center>"

  'data row

  response.write RS.GetString (,,"</td><td align=center>","</td></tr><tr><td

align=center>", "N/A")

  response.write "</td></tr></table>"

end if





Ping Li - Senior Marketing Coordinator

Living Benefits Financial Services, L.L.C.

Carlson Towers

601 Carlson Parkway - Suite 900

Minnetonka, MN 55305



xxx-xxx-xxxx  - Main

xxx-xxx-xxxx  - Direct

xxx-xxx-xxxx  - Fax

xxx-xxx-xxxx  - Toll Free



http://www.livingbenefitsllc.com



NOTICE

The information in this E-Mail message is confidential and legally

privileged information intended only for use of the intended recipient(s)

listed above. If you, the reader(s) are not the intended recipient(s) listed

above, you are hereby notified that you should NOT further disseminate,

forward, or distribute this E-Mail message. If you have received this

message in error, please notify the E-Mail sender. Thank you

NOTICE



Message #2 by "Zee Computer Consulting" <zee@t...> on Tue, 11 Dec 2001 18:55:39 -0800
You can use the Type property of a Field object to discover if the cell

contents are numeric or currency or other, and then change your cell

alignment and also add a dollar sign where needed.



You could discover the field type codes by putting this into a loop:



    Response.Write( "<td>" & oHeader.Type & "</td>")



Does this help? Should I elaborate? For more information, I would recommend

several of the Wrox books, including "ASP 3.0."



Z















----- Original Message -----

From: "Ping Li" <pli@l...>

To: "Access ASP" <access_asp@p...>

Sent: Tuesday, December 11, 2001 9:52 AM

Subject: [access_asp] how to change Header and format cell when use

RS.GetString





> Hello,All,

>

> I was using GetString to create data output table. But the results look

ugly

> because it returned the original header name and no $ dollar sign when

it's

> needed. Could anybody help me with this format? Thanks a lot. Ping

>

> Following are the codes:

>

> if not RS.eof then

>   response.write "<table border=1><tr>"

>   'Header row

>   for each oHeader in RS.Fields

>     response.write "<th>" & oHeader.name & "</th>"

>     next

>   response.write "</tr> <tr><td align=center>"

>   'data row

>   response.write RS.GetString (,,"</td><td

align=center>","</td></tr><tr><td

> align=center>", "N/A")

>   response.write "</td></tr></table>"

> end if

>

>

> Ping Li - Senior Marketing Coordinator

> Living Benefits Financial Services, L.L.C.

> Carlson Towers

> 601 Carlson Parkway - Suite 900

> Minnetonka, MN 55305

>

> xxx-xxx-xxxx  - Main

> xxx-xxx-xxxx  - Direct

> xxx-xxx-xxxx  - Fax

> xxx-xxx-xxxx  - Toll Free

>

> http://www.livingbenefitsllc.com

>

> NOTICE

> The information in this E-Mail message is confidential and legally

> privileged information intended only for use of the intended recipient(s)

> listed above. If you, the reader(s) are not the intended recipient(s)

listed

> above, you are hereby notified that you should NOT further disseminate,

> forward, or distribute this E-Mail message. If you have received this

> message in error, please notify the E-Mail sender. Thank you

> NOTICE

>

>




$subst('Email.Unsub').



Message #3 by "Ken Schaefer" <ken@a...> on Wed, 12 Dec 2001 19:33:20 +1100
Use .getRows if you need to custom format the data, or (not recommend) use

your SQL statement to format the data.



Cheers

Ken



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From: "Ping Li" <pli@l...>

Subject: [access_asp] how to change Header and format cell when use

RS.GetString





: Hello,All,

:

: I was using GetString to create data output table. But the results look

ugly

: because it returned the original header name and no $ dollar sign when

it's

: needed. Could anybody help me with this format? Thanks a lot. Ping

:

: Following are the codes:

:

: if not RS.eof then

:   response.write "<table border=1><tr>"

:   'Header row

:   for each oHeader in RS.Fields

:     response.write "<th>" & oHeader.name & "</th>"

:     next

:   response.write "</tr> <tr><td align=center>"

:   'data row

:   response.write RS.GetString (,,"</td><td

align=center>","</td></tr><tr><td

: align=center>", "N/A")

:   response.write "</td></tr></table>"

: end if

:



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Message #4 by Ping Li <pli@l...> on Wed, 12 Dec 2001 12:53:00 -0600
Ken,

The Beginning of ASP3.0 doesn't recommend using .GetRows. What do you think?



-----Original Message-----

From: Ken Schaefer [mailto:ken@a...]

Sent: Wednesday, December 12, 2001 2:33 AM

To: Access ASP

Subject: [access_asp] Re: how to change Header and format cell when use

RS.GetString





Use .getRows if you need to custom format the data, or (not recommend) use

your SQL statement to format the data.



Cheers

Ken



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From: "Ping Li" <pli@l...>

Subject: [access_asp] how to change Header and format cell when use

RS.GetString





: Hello,All,

:

: I was using GetString to create data output table. But the results look

ugly

: because it returned the original header name and no $ dollar sign when

it's

: needed. Could anybody help me with this format? Thanks a lot. Ping

:

: Following are the codes:

:

: if not RS.eof then

:   response.write "<table border=1><tr>"

:   'Header row

:   for each oHeader in RS.Fields

:     response.write "<th>" & oHeader.name & "</th>"

:     next

:   response.write "</tr> <tr><td align=center>"

:   'data row

:   response.write RS.GetString (,,"</td><td

align=center>","</td></tr><tr><td

: align=center>", "N/A")

:   response.write "</td></tr></table>"

: end if

:



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~








Message #5 by Ping Li <pli@l...> on Wed, 12 Dec 2001 12:59:46 -0600
Zee, I have Beginning ASP3.0, Beginning ASP database and Professional

ASP3.0. But I didn't find much about header and format of .GetString

(eg.$sign in one column and date in another). I'd greatly appreciate if you

could elaborate your suggestion. Thanks. Ping



-----Original Message-----

From: Zee Computer Consulting [mailto:zee@t...]

Sent: Tuesday, December 11, 2001 8:56 PM

To: Access ASP

Subject: [access_asp] Re: how to change Header and format cell when use

RS.GetString





You can use the Type property of a Field object to discover if the cell

contents are numeric or currency or other, and then change your cell

alignment and also add a dollar sign where needed.



You could discover the field type codes by putting this into a loop:



    Response.Write( "<td>" & oHeader.Type & "</td>")



Does this help? Should I elaborate? For more information, I would recommend

several of the Wrox books, including "ASP 3.0."



Z















----- Original Message -----

From: "Ping Li" <pli@l...>

To: "Access ASP" <access_asp@p...>

Sent: Tuesday, December 11, 2001 9:52 AM

Subject: [access_asp] how to change Header and format cell when use

RS.GetString





> Hello,All,

>

> I was using GetString to create data output table. But the results look

ugly

> because it returned the original header name and no $ dollar sign when

it's

> needed. Could anybody help me with this format? Thanks a lot. Ping

>

> Following are the codes:

>

> if not RS.eof then

>   response.write "<table border=1><tr>"

>   'Header row

>   for each oHeader in RS.Fields

>     response.write "<th>" & oHeader.name & "</th>"

>     next

>   response.write "</tr> <tr><td align=center>"

>   'data row

>   response.write RS.GetString (,,"</td><td

align=center>","</td></tr><tr><td

> align=center>", "N/A")

>   response.write "</td></tr></table>"

> end if

>

>

> 

Message #6 by "Ken Schaefer" <ken@a...> on Thu, 13 Dec 2001 11:39:36 +1100
<opinion>

If you're just outputting information without requiring any formatting, I'd

use .getString

If you require custom formatting, use .getRows.

</opinion>



<%

If not objRS.EOF then arrResults = objRS.getRows

objRS.close

Set objRS = Nothing



If isArray(arrResults) then



    For i = 0 to Ubound(arrResults, 2)



        Response.Write("$" & arrResults(0,i) & "<br>" & vbCrLf)



    Next



End If

%>



By iterating the array, you can customised the output much easier than with

.getString. As you write out each array element, you can add your own data

as required.



Cheers

Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From: "Ping Li" <pli@l...>

Subject: [access_asp] Re: how to change Header and format cell when us e

RS.GetString





: Ken,

: The Beginning of ASP3.0 doesn't recommend using .GetRows. What do you

think?



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.



Message #7 by "Zee Computer Consulting" <zee@t...> on Wed, 12 Dec 2001 19:06:54 -0800
Ping,



    I like Ken's method of using the GetRows method to load up a

two-dimensional array, and then customizing the output using FOR...NEXT

loops to move through the rows and the columns within each row.



    If a dollar sign needs to go in front of a field name heading, simply

test for that field name, for example:







' Start cell

OutString = "<th>"



' Check for currency field name(s)

IF uCase(ThisFieldName) = "AMOUNT" THEN

    ' Add dollar sign if it is

    OutString = OutString & "$ "

END IF



' Add the name of the field

OutString = OutString & ThisFieldName



' End the cell

OutString = OutString & "</th>"





    Does this help?



-- Z











----- Original Message -----

From: "Ping Li" <pli@l...>

To: "Access ASP" <access_asp@p...>

Sent: Wednesday, December 12, 2001 10:59 AM

Subject: [access_asp] Re: how to change Header and format cell when us e

RS.GetString





> Zee, I have Beginning ASP3.0, Beginning ASP database and Professional

> ASP3.0. But I didn't find much about header and format of .GetString

> (eg.$sign in one column and date in another). I'd greatly appreciate if

you

> could elaborate your suggestion. Thanks. Ping

>

> -----Original Message-----

> From: Zee Computer Consulting [mailto:zee@t...]

> Sent: Tuesday, December 11, 2001 8:56 PM

> To: Access ASP

> Subject: [access_asp] Re: how to change Header and format cell when use

> RS.GetString

>

>

> You can use the Type property of a Field object to discover if the cell

> contents are numeric or currency or other, and then change your cell

> alignment and also add a dollar sign where needed.

>

> You could discover the field type codes by putting this into a loop:

>

>     Response.Write( "<td>" & oHeader.Type & "</td>")

>

> Does this help? Should I elaborate? For more information, I would

recommend

> several of the Wrox books, including "ASP 3.0."

>

> Z

>

>

>

>

>

>

>

> ----- Original Message -----

> From: "Ping Li" <pli@l...>

> To: "Access ASP" <access_asp@p...>

> Sent: Tuesday, December 11, 2001 9:52 AM

> Subject: [access_asp] how to change Header and format cell when use

> RS.GetString

>

>

> > Hello,All,

> >

> > I was using GetString to create data output table. But the results look

> ugly

> > because it returned the original header name and no $ dollar sign when

> it's

> > needed. Could anybody help me with this format? Thanks a lot. Ping

> >

> > Following are the codes:

> >

> > if not RS.eof then

> >   response.write "<table border=1><tr>"

> >   'Header row

> >   for each oHeader in RS.Fields

> >     response.write "<th>" & oHeader.name & "</th>"

> >     next

> >   response.write "</tr> <tr><td align=center>"

> >   'data row

> >   response.write RS.GetString (,,"</td><td

> align=center>","</td></tr><tr><td

> > align=center>", "N/A")

> >   response.write "</td></tr></table>"

> > end if

> >

> >

> >

>




$subst('Email.Unsub').



Message #8 by Ping Li <pli@l...> on Mon, 17 Dec 2001 10:39:43 -0600
Ken,

Thanks for your email. When I tried, it only returned the first  column. I

have a table with fields named: id, name, value($), price($),date etc. I

need to output with right format for value, price and date. eg. $12,000.00

and 12/17/2001. Is this different or I just used it wrongly?

Thanks,

Ping



-----Original Message-----

From: Ken Schaefer [mailto:ken@a...]

Sent: Wednesday, December 12, 2001 6:40 PM

To: Access ASP

Subject: [access_asp] Re: how to change Header and format cell when us e

RS.GetString





<opinion>

If you're just outputting information without requiring any formatting, I'd

use .getString

If you require custom formatting, use .getRows.

</opinion>



<%

If not objRS.EOF then arrResults = objRS.getRows

objRS.close

Set objRS = Nothing



If isArray(arrResults) then



    For i = 0 to Ubound(arrResults, 2)



        Response.Write("$" & arrResults(0,i) & "<br>" & vbCrLf)



    Next



End If

%>



By iterating the array, you can customised the output much easier than with

.getString. As you write out each array element, you can add your own data

as required.



Cheers

Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

From: "Ping Li" <pli@l...>

Subject: [access_asp] Re: how to change Header and format cell when us e

RS.GetString





: Ken,

: The Beginning of ASP3.0 doesn't recommend using .GetRows. What do you

think?



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.









  Return to Index