MS SQL Server
  Home arrow MS SQL Server arrow Page 4 - Using Data Transformation Services, part 5...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MS SQL SERVER

Using Data Transformation Services, part 5: Package Execution with ASP.NET
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 12
    2005-06-13

    Table of Contents:
  • Using Data Transformation Services, part 5: Package Execution with ASP.NET
  • Creating the package details of the two connections
  • Part B: Create a Web project
  • Write simple code to execute the package
  • Verify the results

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using Data Transformation Services, part 5: Package Execution with ASP.NET - Write simple code to execute the package


    (Page 4 of 5 )

    Place a button on the ExecPackage.aspx design pane and write code in the click event of this button. When you go to the code page, add a reference to the DTS as follows:

    Imports DTS

    With the above imports statement added, you need to instantiate a new instance of the DTS package by using the New keyword as shown here. The intellisense utility should be active, so that you can see all the properties/methods of the Package that can be accessed, as shown here:

    Package properties

    After instantiating a new package, you need to Load the package. Again, intellisense should come in handy. You can load the package saved in the SQL server, or from a repository. In this tutorial, the package saved on the SQL 2000 Server is loaded. Before you take this step, it may be advisable to get (rather, collect) a few of the arguments needed for the load method to work. Specifically you need the following arguments that are self-explanatory. When you save the package, you will be specifying some of these parameters, as we saw in our earlier tutorials.

    All of this in one line !!!!
    LoadFromSQLServer(ServerName as String,
    [ServerUserName as String],
    [ServerPassword as String],
    [Flags as DTS.DTSSQLServerStoragFlags=
    DTSSQLServerStorageFlags.DTSSQLStgFlag_Default],
    [PackagePassword as String],
    [PackageGuid as String],
    [PackageVersionGuid as String],
    [PackageName as String],
    [ByRef pVarPersistStgOfHost as Object=""]
    )
    

    The PackageGuid and PackgeVersionGuid are created by the SQL Server when the package is saved. These may be seen by right clicking the Package-->Properties menu item in the DTS Designer which brings up the property page for the package as shown in the next picture. You may copy the "Guids" directly from this window and insert it into your code.

    The Guids needed for coding

    The package can now be executed by calling the Execute() method of the Package as shown here.

    Execute method

    The code for executing the package is shown here. Make sure you put in the curly braces for the two "guids" correctly.

    Private Sub Button1_Click(ByVal sender As Object, ByVal _
    e As System.EventArgs) Handles Button1.Click
    Dim pkg As New DTS.Package
    pkg.LoadFromSQLServer("XPHTEK", _
    "computer user", "xxxxxxxxx", _
    DTSSQLServerStorageFlags.DTSSQLStgFlag_UseTrustedConnection, _
    "computer user", _
    "{FD8467BD-0FED-4F78-8F7A-C58A7E061AF7}", _
    "{F987D202-6553-42AC-9CFE-41DC46E5EB90}", _
    "ExcelPack3", "")
    pkg.Execute()
    Label1.Text = "Package Executed"
    End Sub
    

    More MS SQL Server Articles
    More By Jayaram Krishnaswamy


     

    MS SQL SERVER ARTICLES

    - Completing the Introduction to Transact-SQL
    - A Brief Introduction to Transact-SQL
    - Lookups and Blocking Bad Data
    - Field Validation Rules for Blocking Bad Data
    - Using Masks to Block Bad Data
    - Blocking Bad Data
    - Using @@ROWCOUNT and TABLE Variables for Dat...
    - How to Use Variables, IF and CASE in Databas...
    - Creating Important Aspects of Notification S...
    - Working wth Variables in Database Interactio...
    - Delving Deeper into Notification Services
    - Notification Services
    - Building a Multi-table Report with SQL 2005 ...
    - A Secure Way of Building Connection Strings
    - Transferring a Database Using the SSIS Desig...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway