All source code in ASP/ VbScript Ask a ASP/ VbScript Pro Discussion Forum Categories All jobs in ASP/ VbScript
Quick Search for:  in language:    
Just,Copy,Paste,Code,into,file,make,extension
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
ASP/ VbScript Stats

 Code: 281,486. 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.
Click here to see a screenshot of this code!Mess Officer Management System (Sistem Pengurusan Mess Pegawai)
By Mohd Fauzi on 11/23

(Screen Shot)

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!



 
 
   

TextFile vs DataBase

Print
Email
 
VB icon
Submitted on: 1/30/2001 11:50:18 PM
By: ~:. Jeff 'Capes' .:~  
Level: Intermediate
User Rating: Unrated
Compatibility:ASP (Active Server Pages), HTML, VbScript (browser/client side)

Users have accessed this code 8268 times.
 
 
     Just Copy & Paste the Code into a file and make the extension .asp (but i quess you allready knew that ;] ) [everything will explain itself]
 
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: TextFile vs DataBase
    ' Description:Just Copy & Paste the Code
    '     into a file and make the extension .asp 
    '     (but i quess you allready knew that ;] )
    '     
    [everything will explain itself]
    ' By: ~:. Jeff 'Capes' .:~
    '
    ' Assumes:see top of the code
    '
    'This code is copyrighted and has    ' limited warranties.Please see http://w
    '     ww.Planet-Source-Code.com/vb/scripts/Sho
    '     wCode.asp?txtCodeId=6475&lngWId=4    'for details.    '**************************************
    
    	<%
    '	IMPORTANT!!!! ==> 	BEFORE YOU START
    '     VIEWING THIS PAGE
    '					MAKE A FILE CALLED "txt_DB.txt" an
    '     d store
    '					it in the same <dir> as this
    '     ASP page!
    '					It doesn't matter what text is in 
    '     the file!
    '					(leave it blank)
    '
    '					but I added this:
    '
    '					Started = "26 januari 2001, 12:47:
    '     18"
    '					HitsTotal = "596"
    Response.write vbCrLf & "<HTML>"
    Response.write vbCrLf & "<HEAD>"
    Response.write vbCrLf & "<TITLE>" & "TextFile vs DataBase by ~:. Jeff 'Capes' .:~" & "</TITLE>"
    Response.write vbCrLf & "</HEAD>"
    Response.write vbCrLf & "<BODY BGCOLOR='lightyellow' topmargin='50' leftmargin='200'>"
    Response.write vbCrLf & "<FONT face='Arial Narrow' SIZE='3' COLOR='#000000'>"
    '		========		Start txt_DB.txt Viewing			
    '     =======
    Response.write vbCrLf & BeginTable
    Response.write vbCrLf & BeginRow
    Response.write vbCrLf & CellLeft
    Response.write vbCrLf & 		"ASP CODE made on"
    Response.write vbCrLf & EndCell
    Response.write vbCrLf & CellRight
    Response.write vbCrLf & 		GetValueFromFile("Started")
    Response.write vbCrLf & EndCell
    Response.write vbCrLf & EndRow
    Response.write vbCrLf & BeginRow
    Response.write vbCrLf & CellLeft
    Response.write vbCrLf & 		"Last Modification"
    Response.write vbCrLf & EndCell
    Response.write vbCrLf & CellRight
    Response.write vbCrLf & 		Date & " at " & Time
    Response.write vbCrLf & EndCell
    Response.write vbCrLf & EndRow
    Response.write vbCrLf & BeginRow
    Response.write vbCrLf & CellLeft
    Response.write vbCrLf & 		"Total hits since start "
    Response.write vbCrLf & EndCell
    Response.write vbCrLf & CellRight
    						Call SaveValueToFile ("HitsTotal", (GetValueFromFile("HitsTotal") + 1))
    Response.write vbCrLf &			GetValueFromFile("HitsTotal")
    Response.write vbCrLf & EndCell
    Response.write vbCrLf & EndRow
    Response.write vbCrLf & EndTable
    						
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & "NEW ADDED VALUES:"
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & "<BR>"
    '		=====> UNDER HERE YOU WILL SEE THA
    '     T THE FILE IS ADDED WITH THE VALUES CALE
    '     D BENEETH! <====
    Response.write vbCrLf & GetValueFromFile("Started")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("HitsTotal")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("StrComment3")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("StrComment4")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("StrComment5")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("StrComment6")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("StrComment7")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("StrComment8")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("StrComment9")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("StrComment10")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("StrComment11")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("StrComment12")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("StrComment13")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("StrComment14")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("StrComment15")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("StrComment16")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("StrComment17")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("StrComment18")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("StrComment19")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("StrComment20")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & GetValueFromFile("StrComment21")
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & "<CENTER>"
    Response.write vbCrLf & "<FONT COLOR='RED' SIZE='1'>"
    Response.write vbCrLf & "ASP coded by:" & "<BR>"
    Response.write vbCrLf & "~ : . Jeff 'Capes' . : ~" & "<BR>"
    Response.write vbCrLf & "<BR>"
    Response.write vbCrLf & "WebSite:"
    Response.write vbCrLf & "<BR><A HREF='http://www.rendo.dekooi.nl/~jeff' TARGET='_BLANK'>"
    Response.write vbCrLf & "WebSite click here" & "</A>"
    Response.write vbCrLf & "</CENTER>"
    Response.write vbCrLf & "</BODY>"
    Response.write vbCrLf & "</HTML>"
    	%>
    	<%
    'set some constants to make it easier (l
    '     ess typing) for us!
    	Const BeginTable	= "<TABLE ALIGN='LEFT' BORDER='3' cellspacing='0' bordercolor='black'>"
    	Const BeginRow	= "	<TR>"
    	Const CellLeft	= "		<TD bgcolor='#FF6347' align='right' border='2'>"
    	Const CellRight	= "		<TD bgcolor='#FFFFCC' align='left'>"
    	Const EndCell	= "		</TD>"
    	Const EndRow	= "	</TR>"
    	Const EndTable	= "</TABLE>"
    '			+ ----------------------------------
    '     ----------- +
    '			|								|
    '			|	BEGIN OF FILE MANAGING			|
    '			|								|
    '			+ ----------------------------------
    '     ----------- +
    		'Open the file and read a specified line# (string),
    		'then erase the String comment (we don't wanna see that!)
    		'Then we Do Call SaveValueToFile function so we update 
    		'the last string!
    	function GetValueFromFile(StrComment)
    	Dim FileName, servObj, TxtFile, Char, SearchStr, EndComment
    	FileName = Server.MapPath("txt_DB.txt")
    	Set servObj = Server.CreateObject("Scripting.FileSystemObject") 	
    	Set TxtFile = servObj.OpenTextFile(FileName, 1, 0, 0)	
    	FileName = TxtFile.ReadAll
    	
    			Do
    			Char = Char +1
    			SearchStr = Mid(FileName, Char, Len(StrComment))
    				if SearchStr = StrComment Then
    					
    					EndComment = Char
    					Exit Do			'This is the Trick!
    							
    				Else 
    				 	SearchStr = "0"		'We make a new entree!
    					EndComment = Char
    				End if
    			Loop Until Char >= Len(FileName)
    			
    	
    		
    			
    			if SearchStr = StrComment Then
    				GetValueFromFile = Mid(FileName, EndComment +3)
    			'the +3 ment that we found the String we searched For
    			'but Then move 3 characters forwards so we stop by the
    			'character "
    			'i.e: 	you searched For TotalHits,
    			'	the function searched till the last
    			'	character and that is the 's' so we have
    			' 	To skip 3 characters to come to "ValueTotalHits"
    			'	Then we read between the 2 characters " & " 
    			'	So we Get ValueTotalHits
    				GetValueFromFile = Split(GetValueFromFile, """") (1)
    			Else
    				Call SaveValueToFile(SearchStr, StrComment)
    			End if
    		TxtFile.Close
    		Set TxtFile = nothing
    		Set servObj = nothing
    		
    		
    	End function 
    		'Save the specified String
    	function SaveValueToFile(StrComment, NewValue)
    		
    		Dim FileName, OldValue, servObj, TxtFile, Code, NewComment
    		FileName = Server.MapPath("txt_DB.txt")
    		Set servObj = server.CreateObject("Scripting.FileSystemObject") 	
    		Set TxtFile = servObj.OpenTextFile(FileName, 1, 0, 0)
    		Code = TxtFile.ReadAll
    		
    			if StrComment = "0" Then
    				Code = Code & vbCrLf & NewValue & " = " & """" & "0000" & """"
    			Else		
    				OldValue = GetValueFromFile(StrComment)
    			End if
    		TxtFile.Close
    		Set TxtFile = nothing			
    			if StrComment = "0" Then
    			Else
    				Code = Replace(Code, OldValue, NewValue)
    			End if
    		Set TxtFile = servObj.CreateTextFile(FileName)
    		TxtFile.Write Code
    		TxtFile.Close
    		Set TxtFile = nothing
    		Set servObj = nothing
    	End function
    '			+ ----------------------------------
    '     ----------- +
    '			|								|
    '			|		END FILE MANAGING				|
    '			|								|
    '			+ ----------------------------------
    '     ----------- +
    	%>

 
 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 Intermediate 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
9/30/2003 9:25:01 AMBoris Bjelosevic

Where can I find txt_DB.txt file?
(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.