使用GetString - msdn帐户将CSV读入记录集 [英] Reading CSV into recordset using GetString - msdn account

查看:65
本文介绍了使用GetString - msdn帐户将CSV读入记录集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两(2)个问题。


我遇到一点困难,不得不求助于工作。

我已经发现了一个bug,虽然声明这个bug只在ODBC中,我不会使用
。它似乎也在OLEDB驱动程序中。


我的连接是:

conn.Open" Provider = Microsoft.Jet.OLEDB.4.0; Data源= QUOT; &安培; strPath&英寸;" &

Extended Properties =''Text; HDR = NO; FMT = Delimited''"


我从这里获得信息:
http://msdn.microsoft.com/library/de...ng03092004.asp

我使用的是schema.ini文件,其中包含:


[austin.csv]

格式= CSVDelimited


Col1 = personid文件

Col2 = currDate文件

Col3 = transCode文件

Col4 = caseNum文字

Col5 = caseType文字

Col6 = defName文本

Col7 =未知文本


1. csv文件中的第一行被忽略,就好像它是一个标题

行。我通过在文件中添加一个空行来验证然后我能够看到第一条记录,现在是第二条记录。


我读过这是一个错误,但对于FirstRowHasNames。这不是我使用的

但是效果与HDR = NO相同。

但是,由于ODBC驱动程序中的错误,指定FirstRowHasNames

设置目前无效。换句话说,Excel ODBC驱动程序(MDAC

2.1及更高版本)始终将指定数据源中的第一行视为

字段名称。


参考: http://support.microsoft.com/ kb / 257819


我发现另一篇文章折叠我在schema.ini中使用其他东西

文件:
< a rel =nofollowhref =http://www.aspdb.com/Site/tor/Manual04/T_csvtext.shtmtarget =_ blank> http://www.aspdb.com/Site/tor/Manual04 /T_csvtext.shtm


ColNameHeader = False


我当前的schema.ini:

[ austin.csv]

格式= CSVDelimited

ColNameHeader = False


Col1 = personid文件

Col2 = currDate Text

Col3 = transCode文件

Col4 = caseNum文件

Col5 = caseType文本

Col6 = defName文字

Col7 =未知文字


我现在获得第一行w不需要空白行。


我当前的连接字符串:

conn.Open" Provider = Microsoft.Jet.OLEDB.4.0; Data Source = QUOT; &安培; strPath&英寸;" &

扩展属性=文本

2.我使用rs.GetString得到一个空白行,但结尾处。


我的行:

arrAccounts = split(rs.GetString(adClipString ,,,,""),vbCr)


我以为也许它返回一个空白行,因为我结束了我的光标,
$ c $ b在csv文件的最后一行空行。我有这个问题使用FSO和

CSV文件。我删除了它,但我仍然有问题。


我可以通过将我的上限减少1来超越它但感觉就像

a解决方法。


for i = 0 to ubound(arrAccounts) - 1

lprt arrAccounts(i)

next


此问题的完整来源:

dim conn,rs,strPath,arrAccounts,arr,i

设置conn = Server.CreateObject(" ; ADODB.Connection")

设置rs = Server.CreateObject(" ADODB.Recordset")

strPath = Server.Mappath(" / csv /")

conn.Open" Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" &安培; strPath&英寸;" &

" Extended Properties = Text"

adLockOptimistic,adCmdText

arrAccounts = split(rs.GetString(adClipString ,,,,""),vbCr)

rs.Close

for i = 0 to ubound(arrAccounts) - 1

lprt arrAccounts(i)

next


我是否导致这个问题我自己还是这是一个众所周知的问题?


TIA ...


-

Roland Hall

/ *这些信息的分发是希望它有用,但

没有任何保证;甚至没有适销性的暗示保证

或特定用途的适用性。 * /

Technet脚本中心 - http:// www .microsoft.com / technet / scriptcenter /

WSH 5.6文档 - http://msdn.microsoft.com/downloads/list/webdev.asp

MSDN Library - http://msdn.microsoft.com/library/default.asp

I have two(2) issues.

I''m experiencing a little difficulty and having to resort to a work around.
I already found one bug, although stated the bug was only in ODBC, which I''m
not using. It appears to be in the OLEDB driver also.

My connection was:
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & ";" &
"Extended Properties=''Text;HDR=NO;FMT=Delimited''"

I got information from here:
http://msdn.microsoft.com/library/de...ng03092004.asp

I am using a schema.ini file and in it was:

[austin.csv]
Format=CSVDelimited

Col1=personid Text
Col2=currDate Text
Col3=transCode Text
Col4=caseNum Text
Col5=caseType Text
Col6=defName Text
Col7=unknown Text

1. The first line in the csv file was being ignored, as if it was a header
line. I verified by putting a blank line in the file and then I was able to
see the first record, which was now the second line.

I read this was a bug but for FirstRowHasNames. It wasn''t what I was using
but the effect was the same for HDR=NO.
"However, due to a bug in the ODBC driver, specifying the FirstRowHasNames
setting currently has no effect. In other words, the Excel ODBC driver (MDAC
2.1 and later) always treats the first row in the specified data source as
field names."

Ref: http://support.microsoft.com/kb/257819

I found another article that fold me to use something else in the schema.ini
file:
http://www.aspdb.com/Site/tor/Manual04/T_csvtext.shtm

ColNameHeader=False

My current schema.ini:
[austin.csv]
Format=CSVDelimited
ColNameHeader=False

Col1=personid Text
Col2=currDate Text
Col3=transCode Text
Col4=caseNum Text
Col5=caseType Text
Col6=defName Text
Col7=unknown Text

I now get the first row without the need for the blank line.

My current connection string:
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & ";" &
"Extended Properties=Text"
2. I am getting a blank line using rs.GetString but at the end.

My line:
arrAccounts = split(rs.GetString(adClipString,,,,""),vbCr)

I thought perhaps it was returning a blank line because I ended my cursor,
in the csv file on a blank line at the end. I have this issue using FSO and
CSV files. I removed it but I still have the issue.

I am able to get past it by reducing my upperboundary by 1 but it feels like
a work-around.

for i = 0 to ubound(arrAccounts) - 1
lprt arrAccounts(i)
next

Full source for this issue:
dim conn, rs, strPath, arrAccounts, arr, i
Set conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
strPath = Server.Mappath("/csv/")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & ";" &
"Extended Properties=Text"
rs.Open "SELECT DISTINCT caseNum FROM austin.csv", conn, adOpenStatic,
adLockOptimistic, adCmdText
arrAccounts = split(rs.GetString(adClipString,,,,""),vbCr)
rs.Close
for i = 0 to ubound(arrAccounts) - 1
lprt arrAccounts(i)
next

Am I causing the issue myself or is this a known issue?

TIA...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp

推荐答案



" Roland Hall" <无**** @ nonononono.us>在消息中写道

新闻:OI ************** @ TK2MSFTNGP10.phx.gbl ...

:我有两个( 2)问题。



:我遇到一点困难,不得不求助于工作



:我已经发现了一个错误,虽然声明这个错误只在ODBC中,但是这个b $ b我是

:没有使用。它似乎也在OLEDB驱动程序中。



:我的连接是:

:conn.Open" Provider = Microsoft。 Jet.OLEDB.4.0;数据源=" &安培; strPath& " ;;"

&

:扩展属性=''文字; HDR = NO; FMT =定界''"



:我从这里得到的信息:


http://msdn.microsoft.com/library/de...ng03092004.asp



:我使用的是schema.ini文件,其中包含:



:[austin.csv]

:格式= CSVDelimited



:Col1 = personid文字

: Col2 = currDate Text

:Col3 = transCode文件

:Col4 = caseNum文字

:Col5 = caseType文字

:Col6 = defName文本

:Col7 =未知文本



:1。csv文件中的第一行被忽略,好像是一个标题

:行。我通过在文件中添加一个空行验证然后我能够



:看到第一条记录,现在是第二条记录。



:我读到这是一个bug但是对于FirstRowHasNames。这不是我使用

的b $ b:但HDR = NO的效果相同。

:但是,由于ODBC驱动程序中的错误,指定FirstRowHasNames

:设置当前无效。换句话说,Excel ODBC驱动程序

(MDAC

:2.1及更高版本)始终将指定数据源中的第一行视为

:字段名称。"



:参考: http://support.microsoft.com/kb/257819



:我发现另一篇文章折叠我使用

schema.ini

:文件:

http://www.aspdb.com/Site/tor/Manual04/T_csvtext.shtm



:ColNameHeader = False



:我当前的schema.ini:

:[奥斯汀.csv]

:格式= CSVDelimited

:ColNameHeader = False



:Col1 = personid Text

:Col2 = currDate文件

:Col3 = transCode文本

:Col4 = caseNum文本

:Col5 = caseType文字

: Col6 = defName文字

:Col7 =未知文字



:我现在得到第一行而不需要空行。



:我当前的连接字符串:

:conn.Open" Provider = Microsoft.Jet.OLEDB.4.0; Data Source =" ; &安培; strPath& " ;;"

&

:扩展属性=文字





:2。我在最后使用rs.GetString得到一个空行。



:我的行:

:arrAccounts = split(rs.GetString(adClipString ,,,,""),vbCr)



:我想也许它回来了一个空白行,因为我结束了我的光标,

:在csv文件末尾的空白行。我有这个问题使用FSO



:CSV文件。我删除了它,但我仍然有问题。



:我可以通过将我的上限减少1来超越它但感觉

喜欢

:解决方案。



:for i = 0 to ubound(arrAccounts) - 1

:lprt arrAccounts(i)

:next



:此问题的完整来源:

:dim conn,rs,strPath,arrAccounts,arr,i

:设置conn = Server.CreateObject(" ADODB.Connection")

:设置rs = Server.CreateObject(" ADODB.Recordset")

:strPath = Server.Mappath(" / csv /")

:conn.Open" Provider = Microsoft.Jet.OLEDB.4.0;数据源=" &安培; strPath& " ;;"

&

:扩展属性=文本

:rs.Open" SELECT DISTINCT caseNum from austin .csv",conn,adOpenStatic,

:adLockOptimistic,adCmdText

:arrAccounts = split(rs.GetString(adClipString ,,,,""),vbCr)

:rs.Close

:for i = 0 to ubound(arrAccounts) - 1

:lprt arrAccounts(i)

:next



:我是自己造成这个问题还是这是一个已知问题?



:TIA ...



: -

:Roland Hall

:/ *这些信息的分发是希望它有用,但

:没有任何保证;甚至没有适销性的暗示保证

:或适合特定用途的适用性。 * /

:Technet脚本中心 - http:// www.microsoft.com/technet/scriptcenter/

:WSH 5.6文档 -
http://msdn.microsoft.com/downloads/list/webdev.asp

:MSDN Library - http://msdn.microsoft.com/library/default.asp < br $> b $ b:





"Roland Hall" <no****@nonononono.us> wrote in message
news:OI**************@TK2MSFTNGP10.phx.gbl...
:I have two(2) issues.
:
: I''m experiencing a little difficulty and having to resort to a work
around.
: I already found one bug, although stated the bug was only in ODBC, which
I''m
: not using. It appears to be in the OLEDB driver also.
:
: My connection was:
: conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & ";"
&
: "Extended Properties=''Text;HDR=NO;FMT=Delimited''"
:
: I got information from here:
:
http://msdn.microsoft.com/library/de...ng03092004.asp
:
: I am using a schema.ini file and in it was:
:
: [austin.csv]
: Format=CSVDelimited
:
: Col1=personid Text
: Col2=currDate Text
: Col3=transCode Text
: Col4=caseNum Text
: Col5=caseType Text
: Col6=defName Text
: Col7=unknown Text
:
: 1. The first line in the csv file was being ignored, as if it was a header
: line. I verified by putting a blank line in the file and then I was able
to
: see the first record, which was now the second line.
:
: I read this was a bug but for FirstRowHasNames. It wasn''t what I was
using
: but the effect was the same for HDR=NO.
: "However, due to a bug in the ODBC driver, specifying the FirstRowHasNames
: setting currently has no effect. In other words, the Excel ODBC driver
(MDAC
: 2.1 and later) always treats the first row in the specified data source as
: field names."
:
: Ref: http://support.microsoft.com/kb/257819
:
: I found another article that fold me to use something else in the
schema.ini
: file:
: http://www.aspdb.com/Site/tor/Manual04/T_csvtext.shtm
:
: ColNameHeader=False
:
: My current schema.ini:
: [austin.csv]
: Format=CSVDelimited
: ColNameHeader=False
:
: Col1=personid Text
: Col2=currDate Text
: Col3=transCode Text
: Col4=caseNum Text
: Col5=caseType Text
: Col6=defName Text
: Col7=unknown Text
:
: I now get the first row without the need for the blank line.
:
: My current connection string:
: conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & ";"
&
: "Extended Properties=Text"
:
:
: 2. I am getting a blank line using rs.GetString but at the end.
:
: My line:
: arrAccounts = split(rs.GetString(adClipString,,,,""),vbCr)
:
: I thought perhaps it was returning a blank line because I ended my cursor,
: in the csv file on a blank line at the end. I have this issue using FSO
and
: CSV files. I removed it but I still have the issue.
:
: I am able to get past it by reducing my upperboundary by 1 but it feels
like
: a work-around.
:
: for i = 0 to ubound(arrAccounts) - 1
: lprt arrAccounts(i)
: next
:
: Full source for this issue:
: dim conn, rs, strPath, arrAccounts, arr, i
: Set conn = Server.CreateObject("ADODB.Connection")
: Set rs = Server.CreateObject("ADODB.Recordset")
: strPath = Server.Mappath("/csv/")
: conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & ";"
&
: "Extended Properties=Text"
: rs.Open "SELECT DISTINCT caseNum FROM austin.csv", conn, adOpenStatic,
: adLockOptimistic, adCmdText
: arrAccounts = split(rs.GetString(adClipString,,,,""),vbCr)
: rs.Close
: for i = 0 to ubound(arrAccounts) - 1
: lprt arrAccounts(i)
: next
:
: Am I causing the issue myself or is this a known issue?
:
: TIA...
:
: --
: Roland Hall
: /* This information is distributed in the hope that it will be useful, but
: without any warranty; without even the implied warranty of merchantability
: or fitness for a particular purpose. */
: Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
: WSH 5.6 Documentation -
http://msdn.microsoft.com/downloads/list/webdev.asp
: MSDN Library - http://msdn.microsoft.com/library/default.asp
:
:
:


Roland Hall写道:
Roland Hall wrote:
Roland Hall <无**** @ nonononono.us>在消息中写道
新闻:OI ************** @ TK2MSFTNGP10.phx.gbl ...
"Roland Hall" <no****@nonononono.us> wrote in message
news:OI**************@TK2MSFTNGP10.phx.gbl...
我有两(2)个问题。
< snip>
我是自己造成这个问题还是这是一个已知问题?
I have two(2) issues. <snip>
Am I causing the issue myself or is this a known issue?



你能从你的csv发一个小摘录吗?文件,所以我们可以尝试

重现这个?


Bob Barrows


-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。我的From

标题中列出的电子邮件帐户是我的垃圾邮件陷阱,因此我不经常检查它。通过发布到新闻组,您将获得更快的回复。


Can you post a small extract from your csv file so we can attempt to
reproduce this?

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don''t check it very often. You will get a
quicker response by posting to the newsgroup.


Roland Hall写道:
Roland Hall wrote:
" Roland霍尔" <无**** @ nonononono.us>在消息中写道
新闻:OI ************** @ TK2MSFTNGP10.phx.gbl ...
"Roland Hall" <no****@nonononono.us> wrote in message
news:OI**************@TK2MSFTNGP10.phx.gbl...




哦!,我刚刚注意到你修改过的主题。你是msdn用户

这两个针对MS的问题吗?我会看看我是否能找到某人来回报


-

Microsoft MVP - ASP / ASP。 NET

请回复新闻组。我的From

标题中列出的电子邮件帐户是我的垃圾邮件陷阱,因此我不经常检查它。通过发布到新闻组,您将获得更快的回复。



Oh!, I just noticed your revised subject line. Are you an msdn subscriber
and were these two issues directed at MS? I''ll see if I can find someone to
respond

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don''t check it very often. You will get a
quicker response by posting to the newsgroup.


这篇关于使用GetString - msdn帐户将CSV读入记录集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆