broncofan7 Posted October 5, 2012 Share Posted October 5, 2012 (edited) I am attempting to use the writeLine command to write a record out to two different text files. It works fine the first time I am attempting to write the line. However, the second time I am attempting to write the line, it does not write out to the file. This happens to fail with any field that defined as type "text field" in the DB. Varchar fields print just fine twice. SQL_Query = SQL_SELECT & " " & SQL_FROM & " " & SQL_WHERE Set RS = MyConn.Execute(SQL_query) Set fs=Server.CreateObject("Scripting.FileSystemObject")Set ctf1 = fs.CreateTextFile(Server.MapPath("file1.txt"), 2)Set ctf2 = fs.CreateTextFile(Server.MapPath("file2.txt"), 2) ctf1.WriteLine(rs.Fields("text_field"))ctf2.WriteLine(rs.Fields("text_field")) This is an over-simplified example of what I am attempting to do, but it shows what the problem is. I also tried writing to the same file and it fails writing the second time. Anyone know how to resolve this? Edited October 5, 2012 by broncofan7 Link to comment Share on other sites More sharing options...
justsomeguy Posted October 5, 2012 Share Posted October 5, 2012 If you define the connection and those SQL variables, will that example actually produce the problem? Why are you passing the number 2 to CreateTextFile? Link to comment Share on other sites More sharing options...
broncofan7 Posted October 5, 2012 Author Share Posted October 5, 2012 Yes this example will reproduce the problem. In fact, you don't even need to have two different files. This will also do it also. ctf3.WriteLine((rs.Fields("text_field").Value)&" "&_ (rs.Fields("text_field").Value)) Probably need some info about my environment:Microsoft Windows Server 2008 R2 SP1IIS 7.0Database: SQL server 9.00.4035.00 For the 2 that is being passed in, I believe that it was OpenTextFile Method previously and that would allow editing. I must have not gotten rid of it. I removed it and the behavior is the same. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 5, 2012 Share Posted October 5, 2012 Is writing to a file significant? Are you able to output the text to the browser more than once? This question seems to use a different connection string to help work around the problem: http://stackoverflow.com/questions/1673680/sql-server-text-column-affects-results-returned-to-classic-asp They claim that Microsoft has acknowledged the problem. In your case, you can probably store the value from the recordset into a variable, and then use that variable instead of the recordset. Link to comment Share on other sites More sharing options...
broncofan7 Posted October 5, 2012 Author Share Posted October 5, 2012 Thanks. It wouldn't print to the screen either. I stored it in a variable and I am able to access it that way. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now