Quick Search for:  in language:    
Writes,file,jsut,change,things,there
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
ASP/ VbScript Stats

 Code: 176,321. lines
 Jobs: 54. postings

 How to support the site

 
Sponsored by:

 

You are in:

 
Login


 

 


Latest Code Ticker for ASP/ VbScript.
Threaded Discussion Forum
By Bobby Ramsey on 5/22


Click here to see a screenshot of this code!Value Spinner
By Michal Gabrukiewicz on 5/21

(Screen Shot)

Smart Office Manager v1.0
By Sawan Gupta on 5/20


Directory List XML Feed Script
By Jamie T Voss on 5/20


Click here to see a screenshot of this code!Family Planet 1.0
By Jeff Rudolph on 5/16

(Screen Shot)

Xml based user system
By Sock on 5/16


Xml based ip ban system
By Sock on 5/15


Xml Logging system
By Sock on 5/15


ASP Post Forward
By Andrew Friedl on 5/15


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!





Affiliate Sites



 
 
   

Write to File

Print
Email
 
VB icon
Submitted on: 3/17/2000
By: Woody Woodland  
Level: Advanced
User Rating: By 3 Users
Compatibility:ASP (Active Server Pages)

Users have accessed this code 15069 times.
 
 
     Writes to a file, jsut change a few things and there you go!
 
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: Write to File
    ' Description:Writes to a file, jsut cha
    '     nge a few things and there you go!
    ' By: Woody Woodland
    '
    'This code is copyrighted and has    ' limited warranties.Please see http://w
    '     ww.Planet-Source-Code.com/xq/ASP/txtCode
    '     Id.6099/lngWId.4/qx/vb/scripts/ShowCode.
    '     htm    'for details.    '**************************************
    
    Sub saveit
    	'create a new Active Data Objects connection
    	Set conn = server.createobject("ADODB.RecordSet")
    	'open the ODBC System DSN
    	conn.open "usage",dsn, adOpenKeySet, adLockPessimistic, adCmdTable
    	conn.addnew
    	conn("email")=Request.Form("email")
    	conn("IP")=Request.ServerVariables("REMOTE_ADDR")
    	conn("referer")=request.form("referer")
    	conn("browser")=Request.ServerVariables("HTTP_USER_AGENT")
    	conn("date_time")=now
    	conn.update
    	conn.close
    	Set conn = Nothing
    End Sub
    Sub query2csv(dsn,sql)
    whichname="download/contacts.txt"
    myDSN=dsn
    mySQL=sql
    showblank=""
    shownull="<null>"
    linestart=chr(34)
    lineend=chr(34)
    delimiter=chr(34) & "," & chr(34)
    delimitersub=""
    whichFN=server.mappath(whichname)
    Set fstemp = server.CreateObject("Scripting.FileSystemObject")
    Set filetemp = fstemp.CreateTextFile(whichFN, true)
    ' true = file can be over-written if it 
    '     exists
    ' false = file CANNOT be over-written if
    '     it exists
    Set conntemp=server.createobject("adodb.connection")
    conntemp.open myDSN
    Set rstemp=conntemp.execute(mySQL)
    ' this code detects if data is empty
    if rstemp.eof Then
    response.write "No data To convert For SQL statement<BR>"
    response.write mySQL & "<BR>"
    connection.close
    Set connection=nothing
    response.end
    End if
    Do UNTIL rstemp.eof
    thisline=linestart
    For Each whatever In rstemp.fields
    thisfield=whatever.value
    if isnull(thisfield) Then
    thisfield=shownull
    End if
    if trim(thisfield)="" Then
    thisfield=showblank
    End if
    thisfield=replace(thisfield,delimiter,delimitersub)
    thisline=thisline & thisfield & delimiter
    next
    tempLen=len(thisline)
    tempLenDelim=len(delimiter)
    thisline=mid(thisline,1,tempLEN-tempLenDelim) & lineend
    filetemp.WriteLine(thisline)
    ' response.write thisline & "<br>"
    '     
    rstemp.movenext
    LOOP
    filetemp.Close
    Set filetemp=nothing
    Set fstemp=nothing
    rstemp.close
    Set rstemp=nothing
    conntemp.close
    Set conntemp=nothing
    if err.number=0 Then
    response.write "File was converted sucessfully!<BR>"
    response.write "Converted file is at <A href='"
    response.write whichname & "'>" & whichname & "</A>"
    else
    response.write "VBScript Errors Occured!<BR>"
    response.write "Error Number=#<B>" & err.number & "</B><BR>"
    response.write "Error Desc. =<B>" & err.description & "</B><BR>"
    response.write "Help Path =<B>" & err.helppath & "</B><BR>"
    response.write "Native Error=<B>" & err.nativeerror & "</B><BR>"
    response.write "Error Source =<B>" & err.source & "</B><BR>"
    response.write "SQL State=#<B>" & err.sqlstate & "</B><BR>"
    End if
    End Sub


Other 2 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
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
6/27/2001 10:48:12 AM:woah
holy, dang dude thats like 10000 things 
not writing to a text file, not 
everyone has sql
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

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.
 
Name:
Comment:

 

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 | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 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.