| | |
Create a text file
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2009
Posts: 10
Reputation:
Solved Threads: 0
I want to create or export data from the database (SQL Server 2005) to a text file. the data I need is for THAT DAY ONLY. The text file is required by another system and therefore at the end of the day, I need a report on txt for the transactions done in that day.
Guyz, How do I go about this from ASP.NET interface?
HINT
The data is entered into the database via a payment system that I am developing.
Thank you
Guyz, How do I go about this from ASP.NET interface?
HINT
The data is entered into the database via a payment system that I am developing.
Thank you
•
•
•
•
I want to create or export data from the database (SQL Server 2005) to a text file. the data I need is for THAT DAY ONLY. The text file is required by another system and therefore at the end of the day, I need a report on txt for the transactions done in that day.
Guyz, How do I go about this from ASP.NET interface?
HINT
The data is entered into the database via a payment system that I am developing.
Thank you

In ASPX form
<head runat="server">
<title>...</title>
<link rel="stylesheet" href="../../MyStyle.css" type="text/css" />
<meta name="DownloadOptions" content="noopen" />
</head>
<body>In VB code
ASP.NET Syntax (Toggle Plain Text)
Imports System.IO Sub SaveToTextFile() Dim SQL As String = "" Dim FileName As String = "JournalEntry-" & Format(Now, "yyMMddHHmmss") Dim Path As String = Request.PhysicalApplicationPath & "pdf\" & FileName & ".txt" Dim SW As StreamWriter = File.CreateText(Path) SQL = "SELECT TransNo, TrxDate, Narrative, CurrencyID, Amount FROM Trx" Dim CnJE As New SqlClient.SqlConnection If GetCN(CnJE) Then Dim CmJE As New SqlClient.SqlCommand(SQL, CnJE) Dim RdJE As SqlClient.SqlDataReader RdJE = CmJE.ExecuteReader With RdJE While .Read Dim S As String = "" If SetStringValue(.Item("CurrencyID")) = "IDR" Or SetStringValue(.Item("CurrencyID")) = "JPY" Or SetStringValue(.Item("CurrencyID")) = "ITL" Then S = S & Format(.Item("Amount"), "#############") Else S = S & Format(.Item("Amount"), "#############.#0") End If S = S & ";D;" & Format(.Item("TrxDate"), "ddMMyy") & ";" & SetStringValue(.Item("Narrative")) SW.WriteLine(S) S = "" End While SetToNothing(CnJE, RdJE, CmJE) End With End If SW.Flush() SW.Close() Response.Clear() Response.AppendHeader("content-disposition", "attachment; filename=" + FileName + ".txt") HttpContext.Current.Response.ContentType = "application/text" Response.WriteFile(Path) Response.End() Response.Close() End Sub
Thanks
Last edited by Kusno; Sep 24th, 2009 at 4:36 am. Reason: bold-red
NEVER NEVER NEVER GIVE UP
![]() |
Similar Threads
- Create text file (Python)
- Unable to right click and create new text file? (Windows NT / 2000 / XP)
- How to create a text file and place in specific location (windows xp) (C++)
- I want to create text file on clients local drive.Please help. (ASP.NET)
- turning userinput into a text file (C)
- How do you create a text file? (C)
- Output in Text file-How to apply fprintf()? (C)
- 10 line text file (Java)
Other Threads in the ASP.NET Forum
- Previous Thread: Horizontal lines in gridview
- Next Thread: Losing Session Variables in a Frameset
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 activexcontrol advice ajax alltypeofvideos anathor appliances application asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox click commonfunctions dataaccesslayer database datagridview datagridviewcheckbox datalist development dgv dialog dropdownlist dynamically edit expose feedback fileuploader fill flash form formatdecimal formview google gridview gudi iframe iis image javascript list listbox login microsoft mono mouse mssql multistepregistration news numerical opera panelmasterpagebuttoncontrols parent project radio redirect registration relationaldatabases reportemail richtextbox save schoolproject search security select sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 suse textbox tracking treeview unauthorized validatedate validation vb.net video videos view vista visualstudio web webapplications webdevelopemnt webprogramming webservice xsl youareanotmemberofthedebuggerusers





