Click here to Skip to main content
15,895,793 members
Articles / Web Development / IIS

Universal Table Editor

Rate me:
Please Sign up or sign in to vote.
4.86/5 (117 votes)
11 May 2003 1.6M   12.3K   275  
Viewer and Editor for any table in any Database you can reach from your IIS/PWS.
<%
'---------------------------------------------------------------------------
'
'   Project:    UTE - (U)niversal ASP (T)able (E)ditor
'
'   Module:     UTE class - Export Functions
'
'   Version:    3.00
'
'   Comments:   This module does the following things:
'                   1. defines all functions being needed in
'                      export mode
'
'---------------------------------------------------------------------------
'
'   (c) in 2000-2003 by Tom Wellige                    
'   http://www.wellige.com  mailto:tom@wellige.com     
'                                               
'   This project is released under the "GNU General Public License (GPL)" 
'   http://www.gnu.org/licenses/gpl.html
'
'   and is maintained on SourceForge at
'   http://sourceforge.net/projects/ute-asp/
'
'   and can also be found on CodeProject at
'   http://www.codeproject.com/asp/ute.asp
'
'---------------------------------------------------------------------------


''--------------------------------------------------------------------------
'' Name:     ExportToStream
''           ==============
'' 
'' Writes all data in current recordset as comma separated text to the response
'' stream.
''
'' Parameter: 
''		none
''
'' return value:
''		none
''
''--------------------------------------------------------------------------
Private Sub ExportToStream ()

	Dim i
	Dim sLine

	' Clear out the existing HTTP header information
	Response.Buffer = TRUE
	Response.Clear
	Response.ContentType = "text/csv"
	Response.AddHeader "Content-Disposition", "inline;filename=" & m_sTable & ".csv"


	' set RecordSet to get all data
	m_RS.PageSize     = m_RS.RecordCount
	m_RS.AbsolutePage = 1
	m_RS.MoveFirst

	' write Header
	sLine = ""
	for i = 1 to UBound(m_PrimaryKeyFields)
		sLine = sLine & DEF_EXPORT_VAL & m_PrimaryKeyFields(i) & DEF_EXPORT_VAL & DEF_EXPORT_SEP
	next

	for i = 1 to UBound(m_StandardFields)
		sLine = sLine & DEF_EXPORT_VAL & m_StandardFields(i) & DEF_EXPORT_VAL & DEF_EXPORT_SEP
	next

	if sLine <> "" then
		sLine = Left(sLine, Len(sLine)-1)
		Response.Write sLine & vbCrLf
	end if 

	Do Until m_RS.EOF
		sLine = ""
		for i = 1 to UBound(m_PrimaryKeyFields)
			sLine = sLine & DEF_EXPORT_VAL & m_RS(m_PrimaryKeyFields(i)) & DEF_EXPORT_VAL & DEF_EXPORT_SEP
		next
		for i = 1 to UBound(m_StandardFields)
			sLine = sLine & DEF_EXPORT_VAL & m_RS(m_StandardFields(i)) & DEF_EXPORT_VAL & DEF_EXPORT_SEP
		next
		if sLine <> "" then
			sLine = Left(sLine, Len(sLine)-1)
			Response.Write sLine & vbCrLf
		end if 
		m_RS.MoveNext
	Loop

	Response.End

End Sub

%>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
CEO Student
Germany Germany
Tom is in software development for about 15 years. He started with a SHARP MZ80k in Basic and Assembly Language. After collecting some experiance on an ATARI 1040ST he bought his very first IBM XT 286 (incl. 287!) and started to program in Turbo Pascal. He became very familiar with Borland's Turbo Vision and over the last years did a lot of development in C++ (MFC), Visual Basic, VB Script, ASP and SQL. He currently works as senior consultant for Swyx Solutions GmbH, based in Dortmund, Germany.
His absolute favourite is Guinness Wink | ;-) Sláinte!

Comments and Discussions