All source code in ASP/ VbScript Ask a ASP/ VbScript Pro Discussion Forum Categories All jobs in ASP/ VbScript
Quick Search for:  in language:    
code,shows,dynamic,array,storage,data,Records
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
ASP/ VbScript Stats

 Code: 281,252. lines
 Jobs: 101. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login

NEW! LEARNING CENTER
Special educational offers, white papers, webcasts, podcasts

  NEW! Download Rational Performance Tester V8 (download now)
  NEW! Download Rational Functional Tester V8 (download now)
  NEW! Download Rational Service Tester for SOA Quality V8 (download now)
  NEW! Teleconference: Quality In Action - Using Rational Quality Manager with Functional, Performance and Web Service Testing Products (download now)
  NEW! Introducing IBM Rational AppScan Developer Edition – easing security testing by non-security professionals (download now)

 

 


Latest postings for ASP/ VbScript.
Web Online Examination
By Suhas Manjunath Kashyap on 11/7


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!



 
 
   

Donutboy

Print
Email
 
VB icon
Submitted on: 11/5/2000 11:39:08 AM
By: Jeremy Pettit  
Level: Advanced
User Rating: By 8 Users
Compatibility:ASP (Active Server Pages)

Users have accessed this code 12877 times.
 
(About the author)
 
     This code shows the use of a dynamic array for the storage of data. Recordsets are memory hogs, and shouldn't be passed across the server, so why even use one? What I was doing with this code was displaying a list of users on my website. After getting the data, I would have it build a table for the information and create hyperlinks for the appropriate fields. I've seen others do this, but they use recordsets to build them, which defeats its purpose. All the code is done with one trip to the server, so you won't see all those carrot tags being opened and closed throughout my work : )
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

    '**************************************
    ' for :Donutboy
    '**************************************
    I wrote this code, but I was taught this, and hopefully you learn this too. I don't care if you just steal my code, but a good programmer should know how to do this themselves.
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    '**************************************
    ' Name: Donutboy
    ' Description:This code shows the use of
    '     a dynamic array for the storage of data.
    '     Recordsets are memory hogs, and shouldn'
    '     t be passed across the server, so why ev
    '     en use one? What I was doing with this c
    '     ode was displaying a list of users on my
    '     website. After getting the data, I would
    '     have it build a table for the informatio
    '     n and create hyperlinks for the appropri
    '     ate fields. I've seen others do this, bu
    '     t they use recordsets to build them, whi
    '     ch defeats its purpose. All the code is 
    '     done with one trip to the server, so you
    '     won't see all those carrot tags being op
    '     ened and closed throughout my work : )
    ' By: Jeremy Pettit
    '
    ' Inputs:No parameters are used, no reco
    '     rdsets, no command objects. You do need 
    '     to create a connection object though. Af
    '     ter the connection object is created, yo
    '     u pass it a sql string for the data you 
    '     want to bring back. 
    You could create command objects and parameters if you were To use stored procs, but I didn't feel that was necessary For this simple Select statement.
    '
    ' Returns:The only thing being brought b
    '     ack is data. It is obtained by executing
    '     a SQL string with your connection object
    '     also using the GetRows method...
    ##vArray = adoCN.Execute(strSQL).GetRows ##
    The data is stored In a variable. (which in ASP code, all are variants) A dynamic array will be created. Arrays are zero based, so the first field and first record will be zero.
    To Get the information you will call it like this...
    To Get the 2nd record and first field you would use these parameters of your array.
    ##vArray(0,1)##
    '
    ' Assumes:I am using ADO for my code, wh
    '     ich is pretty much used everywhere, that
    's why I use it : )
    '
    'This code is copyrighted and has    ' limited warranties.Please see http://w
    '     ww.Planet-Source-Code.com/vb/scripts/Sho
    '     wCode.asp?txtCodeId=6368&lngWId=4    'for details.    '**************************************
    
    <%@ Language=VBScript %>
    <%
    	Dim vArray
    	Dim i
    	
    	Sub FillArray
    	
    		Dim adoCN
    		Dim strSQL
    		strSQL = "SELECT UserName, FirstName, LastName, Email, Website FROM Users Order by UserName"
    		Set adoCN= server.CreateObject("ADODB.Connection")
    		With adoCN
    			.ConnectionString= "FileDSN=DonutboyWeb"
    							.CursorLocation=3
    			.Open
    			vArray = adoCN.Execute(strSQL).GetRows
    		End With
    		Set adoCN=NOTHING
    		
    	End Sub
    	response.write "<HTML>"
    	response.write "<HEAD>"
    	response.write "<META NAME='GENERATOR' Content='Microsoft Visual Studio 6.0'>"
    	response.write "</HEAD>"
    	response.write "<BODY>"
    	response.write "<H1>User Directory</H1>"
    		
    	FillArray()
    	
    	
    	Response.Write "<TABLE border=1 cellPadding=1 cellSpacing=1 ><TH colspan=2>User Name</TH><TH colspan=2>First Name</TH>"
    	Response.Write "<TH colspan=2>Last Name</TH><TH colspan=2>Email</TH><TH colspan=2>Website</TH>"
    	For i = 0 To UBOUND(vArray,2)
    		Response.Write "<TR>"
    		Response.Write "<TD colspan=2>" & vArray(0,i) & "</TD>"
    		Response.Write "<TD colspan=2>" & vArray(1,i) & "</TD>"
    		Response.Write "<TD colspan=2>" & vArray(2,i) & "</TD>"
    		if instr(1,vArray(3,i),"@") Then
    			Response.Write "<TD colspan=2><A href='mailto:" & vArray(3,i) & "'>" & vArray(3,i) & "</A></TD>"
    		Else
    			Response.Write "<TD colspan=2>" & vArray(3,i) & "</TD>"
    		End if
    		if INSTR(1,vArray(4,i),"http://") Then
    			Response.Write "<TD colspan=2><A href='" & vArray(4,i) & "'>" & vArray(4,i) & "</A></TD>"
    		Else
    			Response.Write "<TD colspan=2>" & vArray(4,i) & "</TD>"
    		End if
    		Response.Write "</TR>"
    	Next 
    	Response.Write "</TABLE></BODY></HTML>"
    %>

 
 Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:
 
Your Vote!

What do you think of this code(in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
8/25/2004 9:48:47 AMmbailey

First, yes, using the getRows() method is faster.

Not sure what fear you have of recordsets - My ASP/VBScript/Javascript solutions use recordsets AT THE SERVER and the resultant HTML is then passed out of IIS. No recordset is passed across any server as you've stated in your description.
(If this comment was disrespectful, please report it.)

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author from the email account you registered on the site, so you can correspond directly.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
To post feedback, first please login.


 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | ASP/ VbScript Home | Site Home | Other Sites | Open Letter from Moderators | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997-2008 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.   Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.