dbTalk Databases Forums  

Run DTS from C#

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Run DTS from C# in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
rudolf.ball@asfinag.at
 
Posts: n/a

Default Run DTS from C# - 11-04-2005 , 07:40 AM






Hi NG,


I am a newbie in DTS and want to do something "magic" with DTS:

I want to import ALL files from a specific folder X into a Table T.
Every file X is checked, there is always the same data in there, like
"ID", "Name", "Amount".
A file X has about 200 MB data.

My question is: can I do this with DTS? If yes, how?
And: how can I pass parameters (eg. filename) to the DTS? Is this
neccessary, or does DTS know "all files of folder X"?

Thank you very much

Rudi


Reply With Quote
  #2  
Old   
sergiu
 
Posts: n/a

Default RE: Run DTS from C# - 11-04-2005 , 10:47 AM






Hi,
The answer is "Yes" you can do it.
How? Well, there are multiple ways of doing this. I'll cover here the
simplest way:

Create a DTS package with SQL Enterprise Manager. Text file as a source, SQL
Server as the destination. Pick one file from that folder and test your DTS.
Make sure it works. Save it.

In C# then, you will have to load package from SQL server, and set the
Datasource property of that Connection (The TextFile source will appear as a
Connection) to the file that you want to import. Looping through the files in
a directory in C# is trivial to do.

In order to be able to work with DTS in C#, I recommend reading the
following page:
http://www.15seconds.com/issue/030909.htm

Of course, google has much more information about this issue, but thats the
minimum that you need to know.

Sergiu.

"rudolf.ball (AT) asfinag (DOT) at" wrote:

Quote:
Hi NG,


I am a newbie in DTS and want to do something "magic" with DTS:

I want to import ALL files from a specific folder X into a Table T.
Every file X is checked, there is always the same data in there, like
"ID", "Name", "Amount".
A file X has about 200 MB data.

My question is: can I do this with DTS? If yes, how?
And: how can I pass parameters (eg. filename) to the DTS? Is this
neccessary, or does DTS know "all files of folder X"?

Thank you very much

Rudi



Reply With Quote
  #3  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Run DTS from C# - 11-04-2005 , 02:43 PM



What part of this is to do with C#?

Anyways. You can import the files on a loop and there is an example
here

Looping, Importing and Archiving
(http://www.sqldts.com/default.aspx?246)

You can pass parameters to a package using a variety of ways and here
are a few.

DTSRUN and the /A switch (along with Global variables in the package)
Disconnected Edit
Through programming language when you call the package.

Connections
(http://www.sqldts.com/default.aspx?101)


Allan

"rudolf.ball (AT) asfinag (DOT) at" <rudolf.ball (AT) asfinag (DOT) at> wrote


Quote:
Hi NG,


I am a newbie in DTS and want to do something "magic" with DTS:

I want to import ALL files from a specific folder X into a Table T.
Every file X is checked, there is always the same data in there, like
"ID", "Name", "Amount".
A file X has about 200 MB data.

My question is: can I do this with DTS? If yes, how?
And: how can I pass parameters (eg. filename) to the DTS? Is this
neccessary, or does DTS know "all files of folder X"?

Thank you very much

Rudi


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.