Add to Favorites    Make Home Page 5324 Online  
 Language Categories  
 Our Services  

Home » ASP Home » Math Home » ASP/SQL AverageNumber

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title ASP/SQL AverageNumber
Description Generates an average number from a set of records, this code was written for an Access DB, Great for getting an average rating which was what it was initially written for.
Category ASP » Math
Hits 362782
Code Select and Copy the Code
<% 'Holds the original Number Dim strNum 'Holds the new fixed number Dim strNumFixed 'Get the ID usually an AutoNumber field, ' Just comment out or supply your own strYourID = Request.QueryString("ID") 'Sets your connection, I used a system D ' SN in this example Set Con = Server.CreateObject("ADODB.Connection") 'Name of your DSN Con = "YourDSN" 'Sets the RecordSet Set RS = Server.CreateObject("ADODB.Recordset") 'Your SQL string, this will generate the ' Average Number "AS" Average all on the S ' erver SQLString = "SELECT AVG(tblOfRecord.the_colum) AS Average FROM tblOfRecord WHERE " SQLString = SQLString & "tblOfRecord.Your_ID='" & strYourID & "' " 'Open it all up RS.Open SQLString,Con 'Get the Averaged number strNum = RS("Average") 'Fix the number so you dont have a bunch ' of 2.3333333,this will display i.e 2.3 strNumFixed = FormatNumber(strNum,1) 'Display the Correct HTML for your numbe ' r, make it to how you wish. Response.Write "<HTML>" Response.Write "<HEAD>" Response.Write "<TITLE>" & "AverageNumber" & "</TITLE>" Response.Write "<META http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"">" 'Dont have To have this Response.Write "</HEAD>" Response.Write "<BODY bgcolor=""#FFFFFF"" text=""#000000"">" Response.Write "<B>" & strNumFixed & "</B>" Response.Write "</BODY>" Response.Write "</HTML>" ' If you are looping through displaying ' more then one average then use the follo ' wing format ' add the same code as above except drop ' the ' strNum = RS("Average") and strNumFixed ' and formatnumber code ' Uncomment this code out ' WHILE NOT RS.EOF ' IF NOT IsNull(RS("Average") ) THEN ' Response.Write "<b>" & FormatNum ' ber(RS("Average"),1) & "</b>" ' ELSE ' Response.Write "no average" ' END IF ' RS.MoveNext ' WEND 'And thats about it works pretty simple ' and alot less code %>

Related Source Codes

Script Name Author
ııııııııııııııııııııı VyomWorld
Resistor color code reader A.Chermarajan.
Telephone Directory dhivya
card swapping game (Mini Project) nityanand
simple hangman-pascalsource Seabert
college dirtectory (Mini Project) msridhar
Poll Application John van Meter
ASP Daily Hit Counter. Tejaskumar Gandhi
To avoid null in asp environment using sql Sami
Maklumbalas webmaster
poll John van Meter
EasyASP Template Engine. TjoekBezoer
Basic Calculator using HTML & Javascript. Patrick M. D Souza
What servers support ASP ? VyomWorld
What is ASP? VyomWorld

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=291


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review