473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

genreation csv file in asp giving problem

hi,
i am using the follwoing code to write a recordset to a csv file

'fcreateFile -file system object

Do While Not oRs.EOF
fcreateFile.Write(oRs.GetString(,1000,",",vbcrlf," ")) 'Write Login
Info
loop

to write the data to csv fle
the sql retuns the data in few seconds but at asp file whehn i cma
writing data to the csv file using the getsring method to generate a
comma soeperated file
then it just hangs if the no of records is more than 10,000
i tried alot of things ultimate this piece of code was giving hassles
if the data is returned in 5 sec it takes around 10 minutes for
writing to the csv file
can you can help me ou how to correct this piece code
for yrt ref my whole code of file genearion is given below

'Download base Summary-----------------------------

<%'-------------------------Title------------------------
On Error Resume Next

'----------------File System
Object----------------------------------------------
Set fs = Server.CreateObject("Scripting.FileSystemObject")
if fs.FileExists(server.MapPath(".") & "\Download\" & strfilename) =
true then
'set fcreateFile = fs.OpenTextFile(server.MapPath(".") &
"\Download\" & strfilename , 2,true)
sFileExists=true
else
Set fcreateFile = fs.CreateTextFile(server.MapPath(".") &
"\Download\" & strfilename ,True)

end if
'-----------RecordSet-----------------------------------
If Err.number <> 0 Then%>
<script>
alert("File-"+'<%=strfilename%>'+"Already Opened."+"\n"+"Please
Close the File and then Click on the Link")
</script>
<%Set fcreateFile=nothing
Response.End
end if

'----------------------Com Object------------------------
set objUtility = Server.CreateObject(objUtilityName)
'-------------------RecordSet---------------------------
Set oRs = Server.CreateObject("ADODB.RecordSet")

'-----------------------Login
Info----------------------------------------------
sLOginInfo="," & "DOWNLOAD BASE SUMMARY REPORT" & vbcrlf & vbCrLf &
_
"Period:" & "," & nProcessMonth & " (" & sMonthName & ")" &
vbcrlf & _
sPersonName & vbcrlf & _
"CCAT ID:" &"," & CStr(nCcatId) & vbcrlf & vbcrlf
fcreateFile.Write(sLOginInfo) 'Write Login Info
'-----------------------------
ssql="some sql query"
Set oRs = objUtility.fncRunSQLReturnRS(sSql)

IF oRs.EOF=false then
sHeader="Manager"& "," & "Person" & "," & "Agent" & "," & "SAC
Code"& "," & _
"SAC Name"&","& "From Period" &"," &"To Period"&"," & _
"Revenue Stream"&","& "Current YTD" &"," & _
"Last YTD " &","& "YTD Target" & "," & _
"% Ach YTD" & "," &_
"Last Yr Full" &"," & _
"Full Target" &"," & "% Ach Full"& "," & _
"Growth %"& vbcrlf
fcreateFile.Write(sHeader) 'Header String
fcreateFile.Write(oRs.GetString(,,",",vbcrlf,"") ) 'Manager Sac
Data
Do While Not oRs.EOF
fcreateFile.Write(oRs.GetString(,1000,",",vbcrlf," ")) 'Write Login
Info
Loop

fcreateFile.Write(vbCrLf )
end if
oRs.Close
set oRs=nothing
set objUtility=nothing
fcreateFile.Close
Set fs=Nothing
%>
Jul 19 '05 #1
7 3625
> Do While Not oRs.EOF
fcreateFile.Write(oRs.GetString(,1000,",",vbcrlf," ")) 'Write Login
Info ' did you forget oRs.MoveNext ??? loop

Jul 19 '05 #2
"Aaron Bertrand - MVP" <aa***@TRASHaspfaq.com> wrote in message
news:OC****************@TK2MSFTNGP10.phx.gbl...
Do While Not oRs.EOF
fcreateFile.Write(oRs.GetString(,1000,",",vbcrlf," ")) 'Write Login
Info

' did you forget oRs.MoveNext ???
loop


There an implicit move associated with the GetString method.
Jul 19 '05 #3
Is an error produced when you comment out the "On Error Resume Next"
lline?
Jul 19 '05 #4
"Chris Hohmann" <hohmannATyahooDOTcom> wrote in message news:<OA**************@TK2MSFTNGP10.phx.gbl>...
Is an error produced when you comment out the "On Error Resume Next"
lline?


hi,
guys
the codes works fine if there are say 10,000 records but above that it
just starts dragging... man if takes 25 seconds to fetch the data in recordset
egL: 50,000
when use this piece code to write to file it just drags man.....
guys please tell me the fastest wasy to write to the file......
Do While Not oRs.EOF
fcreateFile.Write(oRs.GetString(,1000,",",vbcrlf," ")) 'Write Login Info
Loop
Jul 19 '05 #5
"Navin" <na******@rediffmail.com> wrote in message
news:5d**************************@posting.google.c om...
"Chris Hohmann" <hohmannATyahooDOTcom> wrote in message news:<OA**************@TK2MSFTNGP10.phx.gbl>...
Is an error produced when you comment out the "On Error Resume Next"
lline?


hi,
guys
the codes works fine if there are say 10,000 records but above that

it just starts dragging... man if takes 25 seconds to fetch the data in recordset egL: 50,000
when use this piece code to write to file it just drags man.....
guys please tell me the fastest wasy to write to the file......
Do While Not oRs.EOF
fcreateFile.Write(oRs.GetString(,1000,",",vbcrlf," ")) 'Write Login Info Loop


The short answer is that the following line is retrieving and writing
ALL the records in the recordset at one time so the Do..Loop is never
entered:

fcreateFile.Write(oRs.GetString(,,",",vbcrlf,"") ) 'Manager Sac Data

Having said that, here are a few more questions
1. What the Database? Version? Table Structure?
2. What are the specifics of objUtilityName and fncRunSQLReturnRS. Why
do you need a custom object to open a recordset?

How about something like this:

<%
Dim sFile,fso,f,cn,rs
sFile = Server.MapPath(".") & "\Download\Foo.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(sFile,2,True)
f.WriteLine "Manager,Person,Agent,SAC Code,SAC Name,From Period,To
Period,Revenue Stream,Current YTD,Last YTD,YTD Target,Ach YTD,Last Yr
Full,Full Target,Ach Full,Growth %"
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cn.Open "FILE NAME=C:\SomePathOutsideAppRoot\MyDB.UDL"
cn.spLoginInfo rs
Do While Not rs.EOF
f.Write rs.GetString(2,100,",",vbCRLF,"")
Loop
rs.Close : Set rs = Nothing
cn.Close : Set cn = Nothing
f.Write vbCRLF
f.Close : Set f = Nothing
Set fso = Nothing
%>

HTH
-Chris
Jul 19 '05 #6
1>Database-oracle
2>objUtilityName-com object
fncRunSQLReturnRS-method in my com object
i have dll registered under mts
i create the com object using the server.createobject .

here the code which i use in my com object.

and the point is my sql runs in 10 sec on oracle server.
but when i execute the sql using ado using the code given below it takes
around a minute to get back the results.
where is the problem lies...
1>is that due to network speed that oracle is running on diff server
and my webserver is running on diff server.
the transportaion of data takes a lot of time.
2>is the code given n=belwo for executing the sql is slow.
Function FncRunSQLReturnRS(ByVal strsql As String) As ADODB.Recordset
On Error GoTo ErrorHandler
'Set up Command and Connection objects
Dim rs As ADODB.Recordset, cmd As ADODB.Command, conn As ADODB.Connection
Set rs = New ADODB.Recordset
Set cmd = New ADODB.Command
'fnLogEvents "logs.txt", "strSql", strSql
'Run the procedure

cmd.ActiveConnection = getconnectionstring("connection.inc")
cmd.CommandText = strsql
cmd.CommandType = adCmdText
rs.CursorLocation = adUseClient
rs.Open cmd, , adOpenForwardOnly, adLockReadOnly
Set cmd.ActiveConnection = Nothing
Set cmd = Nothing
Set rs.ActiveConnection = Nothing

Set FncRunSQLReturnRS = rs
Exit Function

ErrorHandler:
Set rs = Nothing
Set cmd = Nothing
If Err.Number <> 0 Then
fnLogEvents "logs.txt", "error", Err.Description
End If
End Function
"Chris Hohmann" <hohmannATyahooDOTcom> wrote in message news:<uY**************@TK2MSFTNGP11.phx.gbl>...
"Navin" <na******@rediffmail.com> wrote in message
news:5d**************************@posting.google.c om...
"Chris Hohmann" <hohmannATyahooDOTcom> wrote in message

news:<OA**************@TK2MSFTNGP10.phx.gbl>...
Is an error produced when you comment out the "On Error Resume Next"
lline?


hi,
guys
the codes works fine if there are say 10,000 records but above that

it
just starts dragging... man if takes 25 seconds to fetch the data in

recordset
egL: 50,000
when use this piece code to write to file it just drags man.....
guys please tell me the fastest wasy to write to the file......
Do While Not oRs.EOF
fcreateFile.Write(oRs.GetString(,1000,",",vbcrlf," ")) 'Write Login

Info
Loop


The short answer is that the following line is retrieving and writing
ALL the records in the recordset at one time so the Do..Loop is never
entered:

fcreateFile.Write(oRs.GetString(,,",",vbcrlf,"") ) 'Manager Sac Data

Having said that, here are a few more questions
1. What the Database? Version? Table Structure?
2. What are the specifics of objUtilityName and fncRunSQLReturnRS. Why
do you need a custom object to open a recordset?

How about something like this:

<%
Dim sFile,fso,f,cn,rs
sFile = Server.MapPath(".") & "\Download\Foo.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(sFile,2,True)
f.WriteLine "Manager,Person,Agent,SAC Code,SAC Name,From Period,To
Period,Revenue Stream,Current YTD,Last YTD,YTD Target,Ach YTD,Last Yr
Full,Full Target,Ach Full,Growth %"
Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cn.Open "FILE NAME=C:\SomePathOutsideAppRoot\MyDB.UDL"
cn.spLoginInfo rs
Do While Not rs.EOF
f.Write rs.GetString(2,100,",",vbCRLF,"")
Loop
rs.Close : Set rs = Nothing
cn.Close : Set cn = Nothing
f.Write vbCRLF
f.Close : Set f = Nothing
Set fso = Nothing
%>

HTH
-Chris

Jul 19 '05 #7
"Navin" <na******@rediffmail.com> wrote in message
news:5d**************************@posting.google.c om...
1>Database-oracle
2>objUtilityName-com object
fncRunSQLReturnRS-method in my com object
i have dll registered under mts
i create the com object using the server.createobject .

here the code which i use in my com object.

and the point is my sql runs in 10 sec on oracle server.
but when i execute the sql using ado using the code given below it takes around a minute to get back the results.
where is the problem lies...
1>is that due to network speed that oracle is running on diff server
and my webserver is running on diff server.
the transportaion of data takes a lot of time.
2>is the code given n=belwo for executing the sql is slow.

<<Rest of message omitted for brevity>>

Please reread my prior post. The following line is the cause of your
performance problem, please comment it out:

fcreateFile.Write(oRs.GetString(,,",",vbcrlf,"") ) 'Manager Sac Data

Jul 19 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: o'seally | last post by:
solaris/linux admins/rookie_developers that battle with this error are probably all frustrated when it happens. i bet you're also somehow frustrated by this seemingly unsolvable error :-) ...take...
0
by: Fran Tirimo | last post by:
I am developing a small website using ASP scripts to format data retrieved from an Access database. It will run on a Windows 2003 server supporting FrontPage extensions 2002 hosted by the company...
2
by: Fran Tirimo | last post by:
I am developing a small website using ASP scripts to format data retrieved from an Access database. It will run on a Windows 2003 server supporting FrontPage extensions 2002 hosted by the company...
2
by: Dave Stone | last post by:
Does anyone know if it's possible to use the wizard or DTS Designer to accept a source file with the following simplified format: <field1label>: <record1field1value> <field2label>: ...
2
by: Sri | last post by:
I have a simple Web Application hosted on IIS. In this appliaction I am trying to use Microsoft Exception Blocks. It is giving giving me some problem in creating a file on the path specified in my...
3
by: savvy | last post by:
I'm using "Visual Studio 2005 Professional". I'm half way through in my project development. I've created a New Website in the Visual Studio 2005 and developing my project over there. When i wanted...
2
by: Sridhar | last post by:
Hi, I have a web form where it has a <input type=file id=file1> control. I have an Upload button to upload the file. WHen I click on browse and select one file, it is showing the full file path...
5
by: Sendil kumar | last post by:
Hi All, The FtpWebRequest.GetResponse( ) method is not giving "550 File not found exception " when I do a directory list operation on a invalid(not present) directory in HP Unix and Sun Solaris...
6
by: fido19 | last post by:
Once upon a time, there lived a chimpanzee called Luycha Bandor (aka Playboy Chimp). Luycha was unhappily married to Bunty Mona, a short but cute little lady chimp. Luycha was tall and handsome –...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.