dbTalk Databases Forums  

Problem running a DTS package from VB.Net

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


Discuss Problem running a DTS package from VB.Net in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
babou
 
Posts: n/a

Default Problem running a DTS package from VB.Net - 03-23-2005 , 02:51 PM






I have a dts that runs fine from SQL Server Manager but when I try to
run it from VB.NET I get no results. All steps run with no errors but
the tables are not updated and files not created.
I set up all necessary priviledges in the server. I'm using the code
from: http://www.sqldts.com/default.aspx?6,104,265,0,1

My code is:

Dim objDTSPkg As New DTS.Package2
Dim objDTSGV As DTS.GlobalVariable2
Dim objDTSStep As DTS.Step
Dim objNVC As NameValueCollection = New NameValueCollection


Dim strPath As String
Dim isFailed As Boolean
Dim lErr As Long, sSource As String, sDesc As String, sMessage
As String

isFailed = False
Call LockFields()

' Set the global variable value
strGVQType =
Me.CboQuestionaireType.GetItemText(Me.CboQuestiona ireType.SelectedValue)
strGVYear = Me.CboYear.GetItemText(Me.CboYear.SelectedValue)
strGVMonth = Me.CboMonth.GetItemText(Me.CboMonth.SelectedValue)
strGVtransType =
Me.CboTransType.GetItemText(Me.CboTransType.Select edValue)
strGVCapTbl =
dsGVQType.Tables(0).Rows(Me.CboQuestionaireType.Se lectedIndex).Item("CapTable")
strGVCapDirectory =
dsGVQType.Tables(0).Rows(Me.CboQuestionaireType.Se lectedIndex).Item("CapDirectory")
strGVDTSName = strGVACTRDTSName
strPath = strGVDataPath

' Retreive the DTS Package from the SQL Server and remove and
' recreate the global Variables string

objDTSPkg.LoadFromSQLServer(strGVServerName, , , _

DTSSQLServerStorageFlags.DTSSQLStgFlag_UseTrustedC onnection, _
, , , strGVDTSName)
For Each objDTSGV In objDTSPkg.GlobalVariables
If TypeName(objDTSGV.Value) = "String" Then
'Save variable name and value
Dim tmpName As String = objDTSGV.Name
Dim tmpValue As String = CType(objDTSGV.Value, String)
objNVC.Add(tmpName, tmpValue)
'remove variable from collection
objDTSPkg.GlobalVariables.Remove(objDTSGV.Name)
End If
Next

If Len(strGVMonth) <> 2 Then
strGVMonth = "0" & RTrim(LTrim(strGVMonth))
End If
' Add string variable(s) back to collection
Dim i As Integer
For i = 0 To objNVC.Count - 1
If objNVC.Keys(i).ToString = "&Path" Then

objDTSPkg.GlobalVariables.AddGlobalVariable(objNVC .Keys(i).ToString,
strPath)
End If
If objNVC.Keys(i).ToString = "&CapYear" Then

objDTSPkg.GlobalVariables.AddGlobalVariable(objNVC .Keys(i).ToString,
strGVYear)
End If
If objNVC.Keys(i).ToString = "&CapMonth" Then

objDTSPkg.GlobalVariables.AddGlobalVariable(objNVC .Keys(i).ToString,
strGVMonth)
End If
If objNVC.Keys(i).ToString = "&CapType" Then

objDTSPkg.GlobalVariables.AddGlobalVariable(objNVC .Keys(i).ToString,
strGVtransType)
End If
If objNVC.Keys(i).ToString = "&CapSeq" Then

objDTSPkg.GlobalVariables.AddGlobalVariable(objNVC .Keys(i).ToString,
Me.TextSeq.Text)
End If
If objNVC.Keys(i).ToString = "&TableName" Then

objDTSPkg.GlobalVariables.AddGlobalVariable(objNVC .Keys(i).ToString,
strGVCapTbl)
End If
If objNVC.Keys(i).ToString = "&ACTRIn" Then

objDTSPkg.GlobalVariables.AddGlobalVariable(objNVC .Keys(i).ToString,
strGVDataACTR)
End If
If objNVC.Keys(i).ToString = "&ACTROut" Then

objDTSPkg.GlobalVariables.AddGlobalVariable(objNVC .Keys(i).ToString,
strGVACTROut)
End If
Next

' Execute the DTS Package
objDTSPkg.Execute()

' Check for error
For Each objDTSStep In objDTSPkg.Steps
If objDTSStep.ExecutionResult =
DTSStepExecResult.DTSStepExecResult_Failure Then
isFailed = True
objDTSStep.GetExecutionErrorInfo(lErr, sSource, sDesc)
sMessage = sMessage & "Step """ & objDTSStep.Name & _
""" Failed" & vbCrLf & _
vbTab & "Error: " & lErr & vbCrLf & _
vbTab & "Source: " & sSource & vbCrLf & _
vbTab & "Description: " & sDesc & vbCrLf & vbCrLf
MsgBox(sMessage)
Exit For
End If
Next
If isFailed Then
MsgBox(strGVDTSName & " failed", MsgBoxStyle.Critical,
"Coding Data Message")
Else
Call GetACTRCountResults()
MsgBox("Data Successfully coded", MsgBoxStyle.OKOnly,
"Coding Data Message")
End If

Call UnLockFields()
objDTSPkg.UnInitialize()
objDTSStep = Nothing
objDTSPkg = Nothing
objDTSGV = Nothing
objNVC = Nothing


Any help would be appreciated.

Thank you


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 - 2013, Jelsoft Enterprises Ltd.