Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 16th, 2005, 03:45 PM
Authorized User
 
Join Date: Mar 2005
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default Executing dts from vb.net

I have a dts package with a global variable(sCallDate) that I assigned in the package properties. The package executes a stored proc that requires the sCalldate variable.

In the Execute SQL Task of the dts package I have the following: EXEC dbo.uspMyStoredProc, but it really should look like this EXEC dbo.uspMyStoredProc @sCalldate

Here's my vb.net code:
Code:
Private Sub cmdSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSubmit.Click
        Dim bExport As Boolean
        Dim sErrorText As String
        Dim ErrorFlag As Boolean
        Dim sCalldate As String

        Try
        lblResult.Text = ""
        ErrorFlag = False
        sCalldate = txtCalldate.Text

        If Len(Trim(sCalldate)) = 0 Then
            lblResult.Text = "Please Select a Date"
            ErrorFlag = True
        End If

        If ErrorFlag = False Then
            bExport = ExecuteDTS()

            If Trim(sErrorText) <> "Success" Then
                lblResult.Text = sErrorText
            End If
        End If

        Catch ex As Exception
             lblResult.Text = ex.Message
        End Try
End Sub

Public Function ExecuteDTS() As Boolean 
        Dim oPkg As DTS.Package2
        Dim oStep As DTS.Step2
        Dim results As Boolean
        Dim sCalldate As String

        sCalldate = "20050811"
        results = True
        oPkg = New DTS.Package2

        oPkg.LoadFromSQLServer(ServerName:="ServerName", ServerUserName:="user", ServerPassword:="pass", PackageName:="MyPackage")

        oPkg.GlobalVariables.AddGlobalVariable("sCalldate", CType(sCalldate, System.String))

        For Each oStep In oPkg.Steps
            oStep.ExecuteInMainThread = True
        Next

        oPkg.FailOnError = True
        oPkg.Execute()

        For Each oStep In oPkg.Steps
            If oStep.ExecutionResult = DTS.DTSStepExecResult.DTSStepExecResult_Failure Then
                results = False
            End If
        Next

        oPkg.UnInitialize()
        oStep = Nothing
        oPkg = Nothing

        ExecuteDTS = results
End Function
The package executes with no errors, but I'm not getting any data in the text file that the package creates.

I just manually executed the package with the a date in the global variable and I didn't get any data.

It seems like the sCalldate variable is not being passed to the stored procedure.

How can I pass the sCalldate variable to the stored procedure?

Thanks,
Ninel







Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing vb.net console app via report services rickyc1 BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 2 March 31st, 2006 03:56 AM
Executing DTS packages in ASP.NET bmains SQL Server DTS 2 March 17th, 2004 03:50 PM
converting DTS package from VB 6 to VB .NET petroleo Pro VB Databases 0 August 18th, 2003 05:01 PM
DTS packages from VB 6 to VB .NET petroleo SQL Server DTS 0 August 18th, 2003 04:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.