Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

DTS transformation from text file to SQL Server

Posted on 2004-11-02
11
Medium Priority
?
367 Views
Last Modified: 2013-11-30
I have created a DTS package that relies on a Text Input file as the source. The output is a SQL Server database/dataset.

The text input file is referenced via a file DSN. In the file DSN I have outlined the directory, format and that it’s Fixed Length. I have also defined all the fields, sizes and type.

Now in the DTS Connection properties task, Connection1 I point to the file DSN. Then I create a second DTS Connection, Connection2,  properties task which references the output SQL Server database/dataset. I link the two Connection properties with a data transformation pipeline.

Now here is the problem. If I right-click on the data transformation pipeline then select properties then select transformations I get this SQL Error:

HResult of 0X80040e09 (-2147217911) returned. Unexpected error occurred. An error result was returned without an error message.

Why am I getting this problem ?
0
Comment
Question by:ejr19592004
  • 5
  • 4
10 Comments
 
LVL 5

Expert Comment

by:MichaelSFuller
ID: 12480616
You need to specify your source selection first. But before you do that why are you using a DSN for the text file? Why not just use that as the source in DTS and the SQL Server or what you are using as a destination. Then set the fixed length columns right in the package. It would be alot easier to maintain.  
0
 

Author Comment

by:ejr19592004
ID: 12488634
That's the way it was set up initially. But I need the source file location and name to be independent of the DTS settings. File DSN is one way. I tried initially to do it via the DTS objects in VB and couldn't find a way to alter the file name and location.

0
 
LVL 34

Expert Comment

by:arbert
ID: 12489015
Agree with michaelSFuller--get rid of the DSN and let DTS handle it--just add a dynamic properties task to the DTS package.  Set it up to point to your text file name and then you can pass it as a global parm on the DTSRun command line.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:ejr19592004
ID: 12489150
Ok let’s go through the steps:

1.      I drag out a DPT task and call it Test
2.      Which then takes me to the DPT properties window
3.      I select Connection 1 which is my text file and then point to the Data Source property which has the directory\filename
4.      I click on set
5.      Which then takes me to Add/Edit Assignment
6.      I select global variable from the drop down list
7.      Create/Select a variable name of in_loc_file click refresh and then watch the Preview window populate with the Data Source value
8.      Click Ok.

Now I have a Global Variable called in_file_loc which is set to the Data Source for the file.

Now let’s jump to the VB code

DTSGlobalVariables("in_file_loc").Value = "c:\dir\fillename"

And then finally

Dim dtsp As New DTS.Package
   dtsp.LoadFromSQLServer _
    ServerName:=ServerName, _
    ServerUserName:=UserName, _
    ServerPassword:=UserPass, _
    PackageName:="winpassql2txt"
   dtsp.Execute

Because if that’s what you are thinking I couldn’t get this to work on account of the fact that VB kept complaining that DTSGlobalVariables was not defined even though it is referenced in the Project References.

Any more ideas ?
0
 
LVL 34

Accepted Solution

by:
arbert earned 300 total points
ID: 12489201
Hmmm, didn't say anything about VB in your question.

You're not using the object model correctly--there is a good example here:

http://www.sqlservercentral.com/columnists/bknight/executingpackagefromvisualbasic_printversion.asp


Brett
0
 

Author Comment

by:ejr19592004
ID: 12489223
Sorry arbert but it started out as a VB/SQL Sever/DTS post and then go morphed into a VB/DTS/DSN issue. The page you sent looks really good. I will come back to you in an hour or so if you are still awake.

My colleagues are badgering me to go to lunch. It's 12:30 PM in Sydney.

I will continue after lunch.

Eddie
0
 
LVL 34

Expert Comment

by:arbert
ID: 12489320
Sydney, just got back from there--wish I were still enjoying th warm weather!

I
0
 

Author Comment

by:ejr19592004
ID: 12489538
Warm weather ? It's been raining all week. This is the first day that I get to leave my brolly back home.

We are getting into the tropical season here.

Anyho. I am back from din-dins so I am going to get stuck into that most excellent page link you sent across.

Back to you soon.

Eddie
0
 

Author Comment

by:ejr19592004
ID: 12490003
Arbert. That's the ticket. Thanks Mate.
0
 
LVL 34

Expert Comment

by:arbert
ID: 12490367
cheers
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question