Re: DTS connection & BulkInsertTask
From: Allan Mitchell (allan_at_no-spam.sqldts.com)
Date: 05/05/04
- Next message: Thomas Scheiderich: "No Transaction Log update"
- Previous message: Allan Mitchell: "Re: DTS object model"
- In reply to: SP: "Re: DTS connection & BulkInsertTask"
- Next in thread: SP: "Re: DTS connection & BulkInsertTask"
- Reply: SP: "Re: DTS connection & BulkInsertTask"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 5 May 2004 08:48:40 +0100
All my code does is create a text file.
To actually do something with the text file you would need to Add andother
connection, create a datapump task, n transformations objects etc etc.
As I said build the package in designer and then export to VB. This will
show you the things you need to cover in your creating a package.
-- ---------------------------- Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) www.SQLDTS.com - The site for all your DTS needs. I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "SP" <anonymous@discussions.microsoft.com> wrote in message news:D95E0285-01E8-42ED-A2DA-515CEB482988@microsoft.com... > Thanks Allan, It worked for me without any errors. However, I have a question: > > I am not specifying destination sql server table name, so where will be the data inserted? Do I need to give the sql server table name in place of "Text File (Destination)" in tcn.Name = "Text File (Destination) property? If not, where to specify the table name? > > Thanks alot for your prompt and quick help, > SP > > > > > > > ----- Allan Mitchell wrote: ----- > > This is a very quick example > > Dim p As New DTS.Package > > Dim tcn As DTS.Connection > > p.Name = "My Dot Net Package" > > tcn = p.Connections.[New]("DTSFlatFile") > > tcn.DataSource = "C:\MyFile.txt" > > With tcn.ConnectionProperties > > ..Item("Mode").Value = 3 > > ..Item("Row Delimiter").Value = Microsoft.VisualBasic.ControlChars.CrLf > > ..Item("Text Qualifier").Value = """" > > ..Item("File Type").Value = 1 > > ..Item("Column Delimiter").Value = "," > > End With > > > > tcn.Name = "Text File (Destination)" > > tcn.Reusable = True > > tcn.ConnectImmediate = False > > tcn.ConnectionTimeout = 60 > > tcn.UseTrustedConnection = False > > tcn.UseDSL = False > > tcn.ID = 1 > > p.Connections.Add(tcn) > > > > p.SaveToSQLServer(".", , , > DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_UseTrustedConnection, , , , ) > > > > You may want to try building a package in designer | saving as a VB file and > looking at what is generated. > > > > > > > -- > -- > > Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) > www.SQLDTS.com - The site for all your DTS needs. > I support PASS - the definitive, global community > for SQL Server professionals - http://www.sqlpass.org > > > "SP" <anonymous@discussions.microsoft.com> wrote in message > news:76B3A9E9-7248-4BC2-80C8-AE7FA9C153E1@microsoft.com... > > Allan, > >> Ya! I am building a package from scratch and not able to create a text > file connection. The other things you explained clarified some of my other > problems. Thanks for that. Will you please provide me with an example, how > to create a text file connection in vb.net? Any references to add for that? > >> Thanks, > > SP > >> ----- Allan Mitchell wrote: ----- > >> Are you building a package from scratch? > > If so why? > >> No my example does not create a text file connection it will > highlight the > > connections that are text files and you can then go on to manipulate > them/it > > .. is a shortcut name for the local server although I personally do > not use > > it I used it here to shield the name of my actual server > > MyPackage is the name of the package I want to load up. It is a > package > > already built. > >>>> -- > > -- > >> Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) > > www.SQLDTS.com - The site for all your DTS needs. > > I support PASS - the definitive, global community > > for SQL Server professionals - http://www.sqlpass.org > >>> "sp" <anonymous@discussions.microsoft.com> wrote in message > > news:31475B5B-B7FC-4E71-B702-83EB08E55012@microsoft.com... > >> Allan, Can you explain: > >>> p.LoadFromSQLServer(".", , > > ,DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_UseTrustedConnection, , , > > ,"MyPackage") > >>> 1. Will this make a TextFile Connection to Sql Server 2000? > >> 2. Why is "." as first parameter ie Servername? any singnificance > for "."? > >> 3. "Mypackage" is just a string or do we need to create a package > and > > provide that name in the packagename parameter? > >>> Thanks a ton, > >> sp > >>>>>>> ----- Allan Mitchell wrote: ----- > >>> You need to add a ref to the DTS Package Object library > >>> Dim p As New DTS.Package > >>> Dim cn As DTS.Connection > >>> p.LoadFromSQLServer(".", , , > >> > DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_UseTrustedConnection, , , > > , > >> "MyPackage") > >>> For Each cn In p.Connections > >>> If cn.ProviderID = "DTSFlatFile" Then 'text File > >>> 'ideally you would know the name of the connection > >>> 'What is the text qualifier property > >>> MessageBox.Show(cn.ConnectionProperties.Item("Text > Qualifier").Value) > >>> 'Now change it > >>> cn.ConnectionProperties.Item("Text Qualifier").Value = "£" > >>> 'Have a look > >>> MessageBox.Show(cn.ConnectionProperties.Item("Text > Qualifier").Value) > >>>>> End If > >>> Next > >>> p.UnInitialize() > >>>> -- > >> -- > >>> Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP) > >> www.SQLDTS.com - The site for all your DTS needs. > >> I support PASS - the definitive, global community > >> for SQL Server professionals - http://www.sqlpass.org > >>>> "sp" <anonymous@discussions.microsoft.com> wrote in message > >> news:5E8F2BD3-27DF-471D-9BC3-114C07C8FE02@microsoft.com... > >>> Hi, > >>>> 1. Can anyone tell me how to connect a Text File(source) as > > datasource > >> through programming (not through wizard) in vb.net? > >>> 2. Is the Text Qualifier property present in connectionproperties > > of a DTS > >> connection? If so, is it read only or can we modify the > property > > with any > >> text qualifier like single quote, double quotes etc? > >>>> Please provide names of necessary com objects to add reference in > > the > >> project and also syntax of the connection, task &> connectionproperties > >>>> FYI, I am using bulkInsertTask to import from a text file to a > sql > > server > >> 2000 table. Is there still a better way to do this job? > >>>> Thanks for your help, > >>> sp > >>>>
- Next message: Thomas Scheiderich: "No Transaction Log update"
- Previous message: Allan Mitchell: "Re: DTS object model"
- In reply to: SP: "Re: DTS connection & BulkInsertTask"
- Next in thread: SP: "Re: DTS connection & BulkInsertTask"
- Reply: SP: "Re: DTS connection & BulkInsertTask"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|