Problemer med "
Nedenstående script indlæser en csv-fil med fso og udskriver den. Desværre bliver der sat et " foran det første ord i linjen og et " efter det sidste ord i linjen. Filen skal herefter puttes i en database, men anførselstegnene følger med til første og sidste kolonne, og det er jo ikke så smart. desværre er jeg ikke 100% sikker på, at det scriptet her, som "laver" anførselstegnene, men det er der vel en Ekspert, der kan gennemskue?<!-- #include virtual="/Importer/OpenDB.asp"-->
<%
If Request("IPID") <> "" Then
Set RS = conn.execute("SELECT * FROM tblImportProfile WHERE fldIPID = " & Request("IPID"))
If Request.Form("Preview") <> "TRUE" AND RS("fldFieldDelim") > 0 Then
Delimiter = Chr(RS("fldFieldDelim"))
Qualifier = Chr(RS("fldTextQualifier"))
If RS("fldFirstLineName") = -1 Then FirstRowName = True
Else
Delimiter = Request.Form("FieldDelim")
Qualifier = Request.Form("TextQualifier")
If Request.Form("FirstRowContainsName") = "TRUE" Then FirstRowName = True
End If
FixOrDelim = RS("fldFixOrDelim")
Else
FixOrDelim = "ALL"
End If
' Open the file ready for reading
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.OpenTextFile(Server.MapPath("/Importer/Incomming/" & Request("File")), 1, 0)
SELECT CASE (FixOrDelim)
CASE "D"
' Its Delimited so its nice and easy
' Open the file and read in 1 line at a time replacing the Text Qualifier and Delimniter with <TD> etc
' Start Reading the file
i=0
Do While a.AtEndOfStream = False AND i <10
If Qualifier <> "" Then
strDemoTxt = strDemoTxt & "<tr>" & Replace(Replace(Replace(a.ReadLine, Qualifier & Delimiter & Qualifier, "</td><td>"), Qualifier & vbCrLf, "</td>" & vbCrLf), Qualifier, "<td>") & "</tr>" & vbCrLf
Else
strDemoTxt = strDemoTxt & "<tr><td>" & Replace(Replace(a.ReadLine, Delimiter, "</td><td>"), vbCrLf, "</td></tr>" & vbCrLf)
End If
' This is a bug fix cos I cant be bothered to workoout how to do it spot on first time... HEY its friday afternoon... gimme a break already!
strDemoTxt = Replace(strDemoTxt, "<td></tr>", "</td></tr>")
If i=0 AND FirstRowName = True Then
strDemoTxt = Replace(Replace(strDemoTxt, "<tr>", "<tr bgcolor=" & chr(34) & "#CCCCCC" & Chr(34) & ">"), "td>", "th>")
End If
i=i+1
Loop
CASE "F"
Set URS = conn.execute("SELECT * FROM tblIPDetail WHERE fldIPID = " & Request("IPID") & " ORDER BY fldFieldLoc ASC")
ReDim ColInfo(2,0)
n=0
Do While Not URS.Eof
ReDim Preserve ColInfo(2,n)
ColInfo(0,n) = CInt(URS("fldStart"))+1
ColInfo(1,n) = CInt(URS("fldWidth"))
n=n+1
URS.MoveNext
Loop
ColCount = n-1
i=0
Do While a.AtEndOfStream <> True AND i <10
strDemoTxt = strDemoTxt & "<tr>"
srcString = a.ReadLine
For n=0 To ColCount
strDemoTxt = strDemoTxt & "<td>" & Mid(srcString, ColInfo(0,n), ColInfo(1,n)) & "</td>"
Next
If i=0 AND FirstRowName = True Then
strDemoTxt = Replace(Replace(strDemoTxt, "<tr>", "<tr bgcolor=" & chr(34) & "#CCCCCC" & Chr(34) & ">"), "td>", "th>")
End If
i=i+1
strDemoTxt = strDemoTxt & "</tr>"
Loop
CASE ELSE
' Just show top 10 since this is probably just the first stage
i=0
MaxLength = Len(a.ReadLine)+10
Do While a.AtEndOfStream <> True AND i <10
strDemoTxt = strDemoTxt & a.ReadLine & "<BR>"
i=i+1
Loop
For n=0 to MaxLength
strSpacer = strSpacer & "*"
Next
a.close
Set a = Nothing
END SELECT
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table border="1" cellpadding="2" cellspacing="0" bordercolor="#000000">
<%= strDemoTxt %>
<font color="#FFFFFF"><%= strSpacer %></font>
</table>
<%
' Close the file off and kill the object cos we dont need them anymore
'a.Close
'Set a = Nothing
Set fs = Nothing
%>
</body>
</html>
