| | |
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 |
.net 2.0 3.5 ajax appliances application asp asp.net beginner box browser businesslogiclayer button c# c#gridviewcolumn cac checkbox child class compatible confirmationcodegeneration content contenttype control countryselector courier css database datagrid datagridview datalist deadlock deployment development dgv dialog dropdownmenu dynamic dynamically edit embeddingactivexcontrol feedback fileuploader fill findcontrol flash flv form forms grid gridview gudi homeedition hosting iis image javascript jquery list menu mssql multistepregistration nameisnotdeclared novell objects opera order problem ratings redirect registration relationaldatabases rotatepage search security select serializesmo.table sessionvariables silverlight smoobjects sql ssl tracking treeview typeof validatedate validation vb.net virtualdirectory vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment wizard xml xsl





