SQL 2000 DTS 包的 VB 脚本 ActiveX 任务

发布于 2024-07-25 19:33:47 字数 443 浏览 6 评论 0原文

我正在尝试从外部 csv 文件加载数据,在插入 SQL 表之前需要对其进行处理。 读取文件很好,但是当我尝试循环流并使用 SPLIT 函数加载数组时,出现“预期语句结束”错误。

Do While Not txtFile.AtEndOfStream

    strText = txtFile.ReadLine

    Dim dataArray() As String = Split(strText, ",")    -- Here's where it breaks

    ...

    build sql statement to insert using the zero based array

    RS.Open strSQL, dbConn, adOpenKeyset

Loop

txtFile.Close

我已经查看了 BOL 和 MSDN,但仍然收到错误。

I'm trying to load data from an external csv file that needs to be massaged before being inserted into a SQL table. Reading the file is fine, but when I try to loop through the stream and load an array using the SPLIT function I get a "Expected End of Statement" error.

Do While Not txtFile.AtEndOfStream

    strText = txtFile.ReadLine

    Dim dataArray() As String = Split(strText, ",")    -- Here's where it breaks

    ...

    build sql statement to insert using the zero based array

    RS.Open strSQL, dbConn, adOpenKeyset

Loop

txtFile.Close

I've looked at the BOL and MSDN, but I'm still getting the error.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

空城缀染半城烟沙 2024-08-01 19:33:47

VBScript 不支持类型变量。 VBScript 不支持在 Dim 语句中赋值。 使用:-

Dim dataArray()
dataArray = Split(strText, ",")

然而,既然这是 DTS 任务,为什么不在转换中创建文本 csv 数据源,而不是手动创建 VBScript 代码来使用 CSV。

VBScript does not support typed variables. VBScript does not support assigning a value in the Dim statement. Use:-

Dim dataArray()
dataArray = Split(strText, ",")

However having said that since this is DTS task why aren't you creating a text csv data source in the transfrom rather than manually creating VBScript code to consume the CSV.

极度宠爱 2024-08-01 19:33:47

根据记忆,SQL 2k DTS 使用 vb 脚本,因此没有类型。

Dim dataArray = split(strText,",")

From memory SQL 2k DTS uses vb scripts so no types.

Dim dataArray = split(strText,",")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文