Failing to register custom dts job correctly? -
02-02-2004
, 08:03 AM
I have made å custom DTS job in visual basic. I started with the dts export
wizard to save visual basic code for a simple export to excel spreadsheet. I
then wanted to timestamp the filename so that the filename itself contains
the date and time of the actual export, example:
MyExportedExcelFile_2004.02.02_08.15.36.xls. So far the DTS job works as
planned, the filename contains date and time.
So far everything works fine. The problem arise when I make the 2nd. custom
dts job. It is exactly the same as the first one, but exports another set of
data to another timestamped filename.
I register the two dts jobs and they seem to be registered successfully. The
big problem is that when I drag the jobs on to the dts designer surface only
job1 works ok. Job 2 changes its icon when dragged on to the surface,
displays itself as job1 and does exactly the same export task as job1.
I have checked and rechecked that I have not mixed the code of the DLL's.
What could be wrong here.
Regards
Tore Gylver
Here is the Code I use to set up the required properties:
Option Explicit
Implements DTS.CustomTask
Public goPackageOld As New DTS.Package
Public goPackage As DTS.Package2
Private mstrTaskName As String
Private mstrDescription As String
Private mstrMessage As String
Private Property Get CustomTask_Properties() As DTS.Properties
'Set CustomTask_Properties = Nothing
End Property
Private Property Get CustomTask_Description() As String
'Implements Task.Description.
CustomTask_Description = mstrDescription
End Property
Private Property Let CustomTask_Description(ByVal strNewDescr As String)
'Implements Task.Description.
mstrDescription = strNewDescr
End Property
Private Property Get CustomTask_Name() As String
'Implements Task.Name.
CustomTask_Name = mstrTaskName
End Property
Private Property Let CustomTask_Name(ByVal strNewName As String)
'Implements Task.Name.
mstrTaskName = strNewName
End Property
Public Property Get Message() As String
'Implements CustTask.Message.
Message = mstrMessage
End Property
Public Property Let Message(ByVal strNewMsg As String)
'Implements CustTask.Message.
mstrMessage = strNewMsg
End Property
Public Property Get Description() As String
'Implements CustTask.Description.
Description = mstrDescription
End Property
Public Property Let Description(ByVal strNewDescr As String)
'Implements CustTask.Description.
mstrDescription = strNewDescr
End Property
Private Sub CustomTask_Execute(ByVal pPackage As Object, ByVal
pPackageEvents As Object, _
ByVal pPackageLog As Object, pTaskResult As
DTS.DTSTaskExecResult)
'MsgBox "Minimum custom task!", vbExclamation
pTaskResult = DTSTaskExecResult_Success
'End Sub
'Here I start calculating the filename:
Dim oFilename As Variant, oyear As Variant, omonth As Variant, _
oday As Variant, ohour As Variant, ominute As Variant, osecond As
Variant
oyear = Year(Date)
omonth = Month(Date)
If Len(omonth) = 1 Then
omonth = "0" & omonth
End If
oday = Day(Date)
If Len(oday) = 1 Then
oday = "0" & oday
End If
ohour = Hour(Time)
If Len(ohour) = 1 Then
ohour = "0" & ohour
End If
ominute = Minute(Time)
If Len(ominute) = 1 Then
ominute = "0" & ominute
End If
osecond = Second(Time)
If Len(osecond) = 1 Then
osecond = "0" & osecond
End If
oFilename = "C:\Inetpub\ftproot\ADSLFremtidigeOrdre_" & oyear & "."
& omonth & "." & oday & "_" & ohour & "." & ominute & "." & osecond & ".xls"
'************************************************* ************************
'From this point I use a standard visual basic code from the DTS export
wizard
'I onlu substitute the export path and filename with ofilename above
'************************************************* ***************
'Microsoft SQL Server 2000
'Visual Basic file generated for DTS Package
'File Name: C:\Documents and Settings\Administrator\My
Documents\ADSLFremtidigeOrdre.bas
'Package Name: ADSLFremtidigeOrdre
'Package Description: Overføring av fremtidige ordre
'Generated Date: 27.01.2004
'Generated Time: 13:49:12
'************************************************* ***************
'Public goPackageOld As New DTS.Package
'Public goPackage As DTS.Package2
'Private Sub Main()
Set goPackage = goPackageOld |