ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 30th, 2003, 10:45 AM
leeolive leeolive is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: London
Posts: 43 leeolive User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
CSV File - don't understand + error problems

Hi

I am completely new to csv files.

I found this code on writing to a csv file within this form. I have modified the connection and command slightly. I keep getting this error and can't figure it out!

Microsoft VBScript compilation error '800a0408'
Invalid character
/Expat/CSV_test.asp, line 38
^
Also, I have not created a csv file - not sure whether I need to create one with the headers/field names etc first. All I have done is the code below. Is this enough to create the csv file?

Much appreciated!
Lee

<%@ Language=VBScript %>
<%
Dim cndb, cmdcsv
Dim rs

Set cndb = server.CreateObject("adodb.connection")
Set cmdcsv = server.CreateObject("adodb.command")
Set rs = server.CreateObject("adodb.recordset")

'set connection to local DNS or change to web host DNS
cndb.CommandTimeout = 15
cndb.CursorLocation = adUseServer
cndb.ConnectionString = "DSN=cjrcls" 'this is for local
'cndb.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="
on error resume next
cndb.Mode = 3 '3 = adModeReadWrite
cndb.open

With cmdcsv
.CommandTimeout = 15
set .ActiveConnection = cndb
.CommandType = adCmdtext
.CommandText = "SELECT * FROM ApplicantDetails"
End with

rs.Open cmdcsv,,adOpenStatic,adLockOptimistic

on error resume next

if err.number <> 0 then
response.write "error connecting to database<br>" &_
"Error: " & err.Description
response.end
end if

If Not rs.EOF Then
rs.movefirst

Dim strTmp, F

set FSO = Server.CreateObject("scripting.FileSystemObject")
set csv = fso.CreateTextFile("C:\Inetpub\wwwroot\csvfile_test.csv", true)

do while not rs.eof
for each F In rs.Fields
strTmp = strTmp & ", " & f.Value ' check f
next
csv.WriteLine(strTmp)
strTmp = ""
rs.movenext
loop

csv.close
end if %>

<html>
<head><title>csv</title></head>
<body>
testing
</body>
</html>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > CSV File - don't understand + error problems


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway