dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: VB
Expertise: Beginner
Nov 8, 2005

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


A Quick Way to Display Text from a Database in ASP

Suppose you are creating a dynamic page in ASP. Most of the page elements are dynamic and you need a few of the headers to have the first letter of each work to be capitalized. With a very small amount of CSS, you can avoid using VBScript for string manipulation. Using text-transform:capitalize you can apply a quick style to any database driven data.

<%
'Create the variables
Dim Conn, RS, SQL

'Set your connection and recordset
Set Conn = Server.CreateObject("ADODB.Connection") 
Set RS = Server.CreateObject("ADODB.Recordset")

'Set the DSN of the connection
Conn.Open "DSN=myODBC"

'create the SQL string
SQL = "Select TopicTitle From Topics Where ID > 0"

'Open the recordset and make it read-only
RS.Open (SQL), Conn,1,1

'loop through recordset
if not RS.EOF then %>

<!-- The "style" attribute of the DIV tag holds the CSS that will transform the text. -->
<div style="text-transform:capitalize"><%=TopicTitle%></div><br>

<% 
'end IF statement and cleanup database info
RS.Close
end if 

Set RS = Nothing
Conn.Close
Set Conn = Nothing
%>
Ken Pendergast
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date