views:

433

answers:

2

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.

+1  A: 

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

Dim dataArray = split(strText,",")
ozczecho
+2  A: 

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.

AnthonyWJones
Thanks Anthony. This worked and the "Part Duex" question I thought was something related and found out that I had not programmed the header for the CSV file correctly.
kntcnrg