×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Need help with syntax

Need help with syntax

Need help with syntax

(OP)
I am writing an ASP page and struggling with the WriteLine command. The SELECT statement works fine, but I want to send the output to a file instead of the display screen

<%@ LANGUAGE="VBScript" %>
<!--#include file="../timeconn.inc" -->

<%

Response.Buffer=True
Response.Clear


Dim objFSO, objTStream
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTStream = objFSO.CreateTextFile("c:\supsvc\Medical\admin\test.txt", True)


SQLStmt = "SELECT * from medtransaction"

objTStream.WriteLine()
objTStream.WriteLine("Need data from SELECT statement to go to file text.txt instead of display screen")
objTStream.WriteLine()

objTStream.Close

Set objTStream = nothing
Set objFSO = nothing

Set RS = Connection.Execute(SQLStmt)

%>


Thanks
JD

RE: Need help with syntax

Are you getting an error?

RE: Need help with syntax

(OP)
I am not getting an error with the select statement, the information is displayed on the screen correctly, but I want the info to go to a text file. I can not figure out the WriteLine syntax to do it.

Thanks

RE: Need help with syntax

http://p2p.wrox.com/access/6909-write-text-file-re...

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.

RE: Need help with syntax

Chris: Why are you posting a 14 year old thread from another forum about VBA???? It has no relevance here.

jd.ford1: There is nothing wrong with your syntax, that's why I asked if you got an error message. So is the problem that "c:\supsvc\Medical\admin\test.txt" is never getting created or is empty? Or is the problem that it does not contain what you expeceted it to contain?

RE: Need help with syntax

(OP)
The test.txt file is being created with "Need data from SELECT statement to go to file text.txt instead of display screen" in the actual file and the information from the select statement is being displayed on the screen.

Thanks

RE: Need help with syntax

The test.txt file is being created with "Need data from SELECT statement to go to file text.txt instead of display screen" in the actual file ...
Yes, that's precisely what the code you posted will do. If you want to put other things in the text file, you would add more WriteLine statements.

...and the information from the select statement is being displayed on the screen.
You have posted no code that will display anything on the screen???

But anyhow, whatever method you are using to display things on the screen, replace that (or duplicate it) with WriteLine

RE: Need help with syntax

(OP)
<%@ LANGUAGE="VBScript" %>
<!--#include file="../timeconn.inc" -->

<%

Response.Buffer=True
Response.Clear

Dim objFSO, objTStream
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objTStream = objFSO.CreateTextFile("c:\supsvc\Medical\admin\test.txt", True)

SQLStmt = "SELECT * from medtransaction"

objTStream.WriteLine
objTStream.WriteLine"Need data from SELECT statement to go to file text.txt instead of display screen"
objTStream.WriteLine
objTStream.Close

Set objTStream = nothing
Set objFSO = nothing

Set RS = Connection.Execute(SQLStmt)

%>

<html>

<head>
<title></title>

<meta name="Microsoft Theme" content="sumipntg 011">
</head>

<body background="../../../_themes/sumipntg/sumtextb.jpg" bgcolor="#FFFFFF" text="#000066" link="#3333CC" vlink="#666699" alink="#990099"><!--mstheme--><font face="verdana,arial,helvetica">


<div align="center"><center>

<!--mstheme--></font><table border="3" bordercolordark="#003366" bordercolorlight="#C0C0C0">
<tr>
<th><!--mstheme--><font face="verdana,arial,helvetica">Date</th>
<th><!--mstheme--><font face="verdana,arial,helvetica">User</th>
<th><!--mstheme--><font face="verdana,arial,helvetica">UIC</th>
<th><!--mstheme--><font face="verdana,arial,helvetica">DODAAC</th>
<th><!--mstheme--><font face="verdana,arial,helvetica">Unit</th>
<th><!--mstheme--><font face="verdana,arial,helvetica">Scope</th>
<th><!--mstheme--><font face="verdana,arial,helvetica">NDCNO</th>
<th><!--mstheme--><font face="verdana,arial,helvetica">Nomenclature</th>
<th><!--mstheme--><font face="verdana,arial,helvetica">UI</th>
<th><!--mstheme--><font face="verdana,arial,helvetica">Cost</th>
<th><!--mstheme--><font face="verdana,arial,helvetica">Quantity</th>
</tr>
<%
Do While not RS.EOF%>

<tr>
<td><!--mstheme--><font face="verdana,arial,helvetica"><%= RS("date_trans") %>&nbsp;<!--mstheme--></font></td>
<td><!--mstheme--><font face="verdana,arial,helvetica"><%= RS("med_user") %>&nbsp;<!--mstheme--></font></td>
<td><!--mstheme--><font face="verdana,arial,helvetica"><%= RS("med_uic") %>&nbsp;<!--mstheme--></font></td>
<td><!--mstheme--><font face="verdana,arial,helvetica"><%= RS("med_dodaac") %>&nbsp;<!--mstheme--></font></td>
<td><!--mstheme--><font face="verdana,arial,helvetica"><%= RS("med_unit") %>&nbsp;<!--mstheme--></font></td>
<td><!--mstheme--><font face="verdana,arial,helvetica"><%= RS("med_scope") %>&nbsp;<!--mstheme--></font></td>
<td><!--mstheme--><font face="verdana,arial,helvetica"><%= RS("ndcno") %>&nbsp;<!--mstheme--></font></td>
<td><!--mstheme--><font face="verdana,arial,helvetica"><%= RS("nomenclature") %>&nbsp;<!--mstheme--></font></td>
<td><!--mstheme--><font face="verdana,arial,helvetica"><%= RS("ui") %>&nbsp;<!--mstheme--></font></td>
<td><!--mstheme--><font face="verdana,arial,helvetica"><%= RS("cost") %>&nbsp;<!--mstheme--></font></td>
<td><!--mstheme--><font face="verdana,arial,helvetica"><%= RS("med_quantity") %>&nbsp;<!--mstheme--></font></td>

</tr>

<% RS.MoveNext
Loop
%>

</table><!--mstheme--><font face="verdana,arial,helvetica">
</center></div>

<p align="center"><a href="../default.asp">Return to Transactions Page</a></p>

<!--mstheme--></font></body>


</html>
<% Connection.Close %>

RE: Need help with syntax

Quote:

Why are you posting a 14 year old thread from another forum ....

Because it's an EXAMPLE of how to code, and is EXACTLY how I learnt to code different things. Take the code that is close and learn how to adapt it.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.

RE: Need help with syntax

Something like this inside the loop should work (not tested)

CODE

<%
objTStream.WriteLine "Date: " & RS("date_trans")
objTStream.WriteLine "User: " & RS("med_user")
objTStream.WriteLine "UIC: " & RS("med_uic")
objTStream.WriteLine "DODAAC: " & RS("med_dodaac")
objTStream.WriteLine "Unit: " & RS("med_unit")
objTStream.WriteLine "Scope: " & RS("med_scope")
objTStream.WriteLine "NDCNO: " & RS("ndcno")
objTStream.WriteLine "Nomenclature: " & RS("nomenclature")
objTStream.WriteLine "UI: " & RS("ui")
objTStream.WriteLine "Cost: " & RS("cost")
objTStream.WriteLine "Quantity: " & RS("med_quantity")
%> 

Of course you need to define objTStream before the loop, and close it after the loop

RE: Need help with syntax

(OP)
guitarzan,

I would like to personally "Thank You" for the help. Literally copied and paste to my code and it started running like a champ!!! I can not tell you how many hours I have spent trying to make that work. You make it look easy my man. Again thanks

JD

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close