|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
||||
|
||||
|
possible fso problem
I have an asp script meant to take the first record from my database and write it to a csv file on the server. The code meant to do this is:
Code:
SQL = "SELECT TOP 1 * FROM UserRequest ORDER BY RecordID DESC"
Set aRS = Conn.Execute (SQL)
dim filesavepath
Dim F, Head
'This is where you want to Write the CSV File. This example is a physical path.
filesavepath = "e:\prod\intranet\www-gs\pdh\insertData.csv"
set FSO = Server.CreateObject("scripting.FileSystemObject")
set csvfile = fso.CreateTextFile(filesavepath, true)
'This loops through the database and then writes into CSV format.
'Head is the Field names.
'Body are the actual records
For Each F In aRS.Fields
Head = Head & ", " & F.Name
Next
Head = Mid(Head,3) & vbCrLf
Body = aRS.GetString(,,", ",vbCrLf,"")
csvfile.WriteLine(Head)
csvfile.WriteLine(Body)
csvfile.Close
I do make the connection object earlier in the code, and it works. (That is, it does the stuff to the database that preceedes this code.) When I run the whole page, there are no errors, and everything else works correctly, but the csv file is not generated, which is the point of this code. Are there any problems with my code here, or might the permissions be set wrong on the server? Any help is much appreciated.
__________________
--Dave-- U2kgSG9jIExlZ2VyZSBTY2lzLCBOaW1pdW0gRXJ1ZGl0aW9uaXMgSGFiZXM= |
|
#2
|
|||
|
|||
|
intuition
set csvfile = fso.CreateTextFile(filesavepath, true)
you're code looks right, right here is where i've run into problems before, this line creates the text file, so if it bombs, it bombs and the text file is still created as long as this line just succeeds, it's just blank i think. maybe you haven't set the iuser to be allowed to write to this directory or maybe your path is wrong? I really recommend using mappath to avoid virtual and absolute path errors. why arn't you getting error messages too? if the createastextfile line is the problem usually it tells you (makes debugging MUCH easier), have you enabled it to show debug errors? you can in the folder the asp file resides. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > possible fso problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|