ADODB.RecordSet 不分隔 CSV 列
ADODB.RecordSet doesn't delimit CSV columns
我有一个 VBScript,它使用 ADODB.RecordSet
获取带分隔符的 CSV 文件的所有项目。这是一段脚本:
Set rsSource = Server.CreateObject("ADODB.RecordSet")
Set cnxExcel = CreateObject("ADODB.Connection")
cnxExcel.Provider = "Microsoft.Jet.OLEDB.4.0"
cnxExcel.ConnectionString = "Data Source=" & CheminSource & ";Extended Properties='Text;HDR=YES;FMT=Delimited'"
cnxExcel.Open
rsSource.Open "SELECT * FROM [" & Fichier & "]", cnxExcel, 3
If rsSource.EOF AND rsSource.BOF Then
RecordSetVide = true
Else
rsSource.MoveFirst
NbColonne = 1
For Each adoFld in rsSource.Fields
ReDim Preserve TabColonne(NbColonne)
TabColonne(NbColonne) = adoFld.Name
Next
End If
问题是我得到一个未定界的输出并且分号可见:
item1;item2;item3...
而不是:
item1
item2
item3
...
这段代码在 II6 (W2K) 上 运行 很好,但是当移动到 IIS7.5 (W2008R2) 时,它似乎没有考虑分隔符。
Microsoft Jet OLE DB 4.0
Delimited columns
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\txtFilesFolder\;
Extended Properties="text;HDR=Yes;FMT=Delimited";
The delimiter can be specified in the registry at the following location:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet.0\Engines\Text
"Format" = "TabDelimited"
or
"Format" = "Delimited(;)"
我有一个 VBScript,它使用 ADODB.RecordSet
获取带分隔符的 CSV 文件的所有项目。这是一段脚本:
Set rsSource = Server.CreateObject("ADODB.RecordSet")
Set cnxExcel = CreateObject("ADODB.Connection")
cnxExcel.Provider = "Microsoft.Jet.OLEDB.4.0"
cnxExcel.ConnectionString = "Data Source=" & CheminSource & ";Extended Properties='Text;HDR=YES;FMT=Delimited'"
cnxExcel.Open
rsSource.Open "SELECT * FROM [" & Fichier & "]", cnxExcel, 3
If rsSource.EOF AND rsSource.BOF Then
RecordSetVide = true
Else
rsSource.MoveFirst
NbColonne = 1
For Each adoFld in rsSource.Fields
ReDim Preserve TabColonne(NbColonne)
TabColonne(NbColonne) = adoFld.Name
Next
End If
问题是我得到一个未定界的输出并且分号可见:
item1;item2;item3...
而不是:
item1 item2 item3 ...
这段代码在 II6 (W2K) 上 运行 很好,但是当移动到 IIS7.5 (W2008R2) 时,它似乎没有考虑分隔符。
Microsoft Jet OLE DB 4.0
Delimited columns
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\txtFilesFolder\; Extended Properties="text;HDR=Yes;FMT=Delimited";
The delimiter can be specified in the registry at the following location:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet.0\Engines\Text
"Format" = "TabDelimited"
or
"Format" = "Delimited(;)"