|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > CSV File - don't understand + error problems |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|