September 10, 2010 at 1:09 pm
I need to import a text file using a script task, vb.net and a schema.ini file. I can code the vb in Visual Studio but was wondering how I would get this to work in SSIS Script Task. Here is what I have so far any assistance would be greatly appreciated. Thanks
Dim path As String = "C:\testfile.txt"
Dim SQL As String = "SELECT * FROM " & IO.Path.GetFileName(path) & " "
Dim cnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source='" & IO.Path.GetDirectoryName(path) & _
"';Extended Properties=" & Chr(34) & _
"Text;HDR=No;FMT=Delimited(~)" & Chr(34) & ";"
Dim adapter As New OleDb.OleDbDataAdapter(SQL, cnString)
Dim table As New DataTable()
adapter.Fill(table)
September 12, 2010 at 7:17 am
Hi,
You should use Script Component, not Script Task and create Script Source. Two recommendations:
- Explicitly define the columns from the source and then define each and every column in the script setup you will insert in the data flow.
- The provider you are using looks like Jet's OLEDB . Use the old ADODB and construct Recordset object, which you will use to read the data from the text file. I recommend this because the approach you have used in your script will load the complete text file in memory before it starts the loading process.
---------------
I'm wondering why you are not using the regular Flat File Connection Manager / Flat File Source? From what I can see you can process this type of file.
September 13, 2010 at 7:10 am
The flat file connection manager does not work for files with uneven column data. It works well in DTS but not in SSIS. The file is also delimited with a tilda characters from the source and not comma and this seems to be a problem also. I agree that this should be in a script component. I guess my quesiton is how to read in and out of the script component with ADO.
September 13, 2010 at 7:19 am
erngreen (9/13/2010)
The flat file connection manager does not work for files with uneven column data. It works well in DTS but not in SSIS. The file is also delimited with a tilda characters from the source and not comma and this seems to be a problem also. I agree that this should be in a script component. I guess my quesiton is how to read in and out of the script component with ADO.
You can define tilda (~) character as delimiter. In the flat file connection manager dialog just type it in.
For the ADO , you have to first include reference to ADO library. Check these resources to find out how to read CSV using ADO recordset:
September 13, 2010 at 7:24 am
This is a pure text file. I know that the tilda can be defined in the flat file connection. I have gone around and around on this issue for months and the flat file connection issue is something that it is a know issue.
September 13, 2010 at 7:33 am
erngreen (9/13/2010)
This is a pure text file. I know that the tilda can be defined in the flat file connection. I have gone around and around on this issue for months and the flat file connection issue is something that it is a know issue.
Please provide an example of your data and a reference to the known issue you mention.
September 13, 2010 at 7:49 am
here are just a couple of posts related to the problem.
http://connect.microsoft.com/SQLServer/feedback/details/126493/uneven-column-count-import-using-ssis
September 13, 2010 at 7:54 am
erngreen (9/13/2010)
here are just a couple of posts related to the problem.http://connect.microsoft.com/SQLServer/feedback/details/126493/uneven-column-count-import-using-ssis
Have you checked this component ?
September 13, 2010 at 7:57 am
While I would like to use this component, I have been unable to get it to install in my enviornment.
September 13, 2010 at 8:04 am
erngreen (9/13/2010)
While I would like to use this component, I have been unable to get it to install in my enviornment.
What's the issue? Have you tried asking a question in the codeplex forum here ?
September 13, 2010 at 8:43 am
The installation goes smoothly but when I go to add it in BI Studio. I get an error.
September 13, 2010 at 8:47 am
September 13, 2010 at 8:51 am
I can post the message but it will probably be some time this afternoon as I have something running in BIDS. I will have to re-create.
September 13, 2010 at 2:09 pm
here is the error message. I have tried to manually install this to GAC with no success. When I go to BIDS --> Toolbox --> Right Click and browse to this dll, I get the error below.
There was an error loading types from assembly 'C:\Program Files\Microsoft SQL Server\100\DTS\PipelineComponents\DelimitedFileReader.dll'
'Could not load file or assembly 'Microsoft.SqlServer.PipelineHost, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.'
September 13, 2010 at 2:21 pm
Viewing 15 posts - 1 through 15 (of 19 total)
You must be logged in to reply to this topic. Login to reply