dbTalk Databases Forums  

DTS pkg to VB6 to VB.Net problem

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


Discuss DTS pkg to VB6 to VB.Net problem in the microsoft.public.sqlserver.dts forum.



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

Default DTS pkg to VB6 to VB.Net problem - 07-13-2004 , 11:53 AM






Hello,

I saved a DTS packaged down to a VB6 module. If I compile
this module in VB6 it runs fine. But I would like to
incorporate the code into a VB.net app. I am having a lot
of problems with this. I have turned Option Strict Off
(for now) and even with that I still get 3 types of error
messages that are beyond me at this time. Does anyone
know how to deal with these types of errors or know where
I could go to find out about these kind of errors?

--Error #1
--------------------------------------------------------
Dim oConnection As DTS.Connection2

oConnection = goPackage.Connections.New("DTSFlatFile")

oConnection.ConnectionProperties("Data Source")
= "C:\test.txt" <--- error on this oConnection

--Interface 'DTS.OleDBProperties' cannot be indexed
because it has no default property--
--------------------------------------------------------

Error #2
--------------------------------------------------------
Public Sub Task_Sub1(ByVal goPackage As Object)

Dim oTask As DTS.Task
Dim oLookup As DTS.Lookup

Dim oCustomTask1 As DTS.DataPumpTask2
oTask = goPackage.Tasks.New("DTSDataPumpTask") <-- error
on gopackage.Tasks....

--Constructor call is valid only as the first statement in
an instance constructor--
--------------------------------------------------------

Error #3
------------------------------------------------------
Public Sub tracePackageError(ByVal oPackage As DTS.Package)
Dim ErrorCode As Long
Dim ErrorSource As String
Dim ErrorDescription As String
Dim ErrorHelpFile As String
Dim ErrorHelpContext As Long
Dim ErrorIDofInterfaceWithError As String
Dim i As Integer

For i = 1 To oPackage.Steps.Count
If oPackage.Steps(i).ExecutionResult =
DTSStepExecResult_Failure Then <--- error here

--Name 'DTSStepExecResult_Failure' is not declared--
-------------------------------------------------------

Any suggestions appreciated.
Thanks,
Rich



Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: DTS pkg to VB6 to VB.Net problem - 07-13-2004 , 12:21 PM






In article <2b6df01c468f9$f84a97c0$a601280a (AT) phx (DOT) gbl>, Rich wrote:
Quote:
Hello,

I saved a DTS packaged down to a VB6 module. If I compile
this module in VB6 it runs fine. But I would like to
incorporate the code into a VB.net app. I am having a lot
of problems with this. I have turned Option Strict Off
(for now) and even with that I still get 3 types of error
messages that are beyond me at this time. Does anyone
know how to deal with these types of errors or know where
I could go to find out about these kind of errors?

--Error #1
--------------------------------------------------------
Dim oConnection As DTS.Connection2

oConnection = goPackage.Connections.New("DTSFlatFile")

oConnection.ConnectionProperties("Data Source")
= "C:\test.txt" <--- error on this oConnection

--Interface 'DTS.OleDBProperties' cannot be indexed
because it has no default property--
--------------------------------------------------------

Error #2
--------------------------------------------------------
Public Sub Task_Sub1(ByVal goPackage As Object)

Dim oTask As DTS.Task
Dim oLookup As DTS.Lookup

Dim oCustomTask1 As DTS.DataPumpTask2
oTask = goPackage.Tasks.New("DTSDataPumpTask") <-- error
on gopackage.Tasks....

--Constructor call is valid only as the first statement in
an instance constructor--
--------------------------------------------------------

Error #3
------------------------------------------------------
Public Sub tracePackageError(ByVal oPackage As DTS.Package)
Dim ErrorCode As Long
Dim ErrorSource As String
Dim ErrorDescription As String
Dim ErrorHelpFile As String
Dim ErrorHelpContext As Long
Dim ErrorIDofInterfaceWithError As String
Dim i As Integer

For i = 1 To oPackage.Steps.Count
If oPackage.Steps(i).ExecutionResult =
DTSStepExecResult_Failure Then <--- error here

--Name 'DTSStepExecResult_Failure' is not declared--
-------------------------------------------------------

Any suggestions appreciated.
Thanks,
Rich


For your first problem does either of these work for you

Dim cn As DTS.Connection

cn = pkg.Connections.[New]("DTSFlatFile")

cn.DataSource = "c:\Text File.txt"

cn.ConnectionProperties.Item("Data Source").Value = "c:\Text File.txt"


And for your second problem I cannot see what you are erroring on as it
is unclear through my word wrapping

Dim oTask As DTS.Task
Dim oLookup As DTS.Lookup

Dim oCustomTask1 As DTS.DataPumpTask2
oTask = dtsImport.Tasks.New("DTSDataPumpTask")
oCustomTask1 = oTask.CustomTask




For your third problem what about

If pkg.Steps.Item(i).ExecutionResult =
DTS.DTSStepExecResult.DTSStepExecResult_Failure Then

End If



Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
www.konesans.com - for all your consultancy needs





Reply With Quote
  #3  
Old   
Rich
 
Posts: n/a

Default Re: DTS pkg to VB6 to VB.Net problem - 07-13-2004 , 12:47 PM



Hi,

Thanks for your reply.

On the first part, your code lines appear to work in my
vb.net code module (have a reference to Microsoft DTS
object library - and using Imports System.DTS - everything
else commented out for now). Even with Option Strict On
these codes lines seem to work:

Dim cn As DTS.Connection
cn = pkg.Connections.[New]("DTSFlatFile")
....
compiler not complaining so far.

As for the second error

oTask = goPackage.Tasks.New("DTSDataPumpTask")

on this line (Error #2) I get this complaint from the
compiler:

"Constructor call is valid only as the first statement in
an instance constructor"

this is happening in

Public Sub Task_Sub1(ByVal goPackage As Object)
....

Should I copy the whole VB6 module for you to look at?

Note: with Option strict on I also get alot of other minor
errors, just syntax stuff like need to say CType(...,
Integer), somthing.ToString, etc - compiler says "No Late
Binding with Option Strict On". But I guess I will wait
till I resolve the big errors first.

Rich



Quote:
-----Original Message-----
In article <2b6df01c468f9$f84a97c0$a601280a (AT) phx (DOT) gbl>,
Rich wrote:
Hello,

I saved a DTS packaged down to a VB6 module. If I
compile
this module in VB6 it runs fine. But I would like to
incorporate the code into a VB.net app. I am having a
lot
of problems with this. I have turned Option Strict Off
(for now) and even with that I still get 3 types of
error
messages that are beyond me at this time. Does anyone
know how to deal with these types of errors or know
where
I could go to find out about these kind of errors?

--Error #1
--------------------------------------------------------
Dim oConnection As DTS.Connection2

oConnection = goPackage.Connections.New("DTSFlatFile")

oConnection.ConnectionProperties("Data Source")
= "C:\test.txt" <--- error on this oConnection

--Interface 'DTS.OleDBProperties' cannot be indexed
because it has no default property--
--------------------------------------------------------

Error #2
--------------------------------------------------------
Public Sub Task_Sub1(ByVal goPackage As Object)

Dim oTask As DTS.Task
Dim oLookup As DTS.Lookup

Dim oCustomTask1 As DTS.DataPumpTask2
oTask = goPackage.Tasks.New("DTSDataPumpTask") <--
error
on gopackage.Tasks....

--Constructor call is valid only as the first statement
in
an instance constructor--
--------------------------------------------------------

Error #3
------------------------------------------------------
Public Sub tracePackageError(ByVal oPackage As
DTS.Package)
Dim ErrorCode As Long
Dim ErrorSource As String
Dim ErrorDescription As String
Dim ErrorHelpFile As String
Dim ErrorHelpContext As Long
Dim ErrorIDofInterfaceWithError As String
Dim i As Integer

For i = 1 To oPackage.Steps.Count
If oPackage.Steps(i).ExecutionResult =
DTSStepExecResult_Failure Then <--- error here

--Name 'DTSStepExecResult_Failure' is not declared--
-------------------------------------------------------

Any suggestions appreciated.
Thanks,
Rich



For your first problem does either of these work for you

Dim cn As DTS.Connection

cn = pkg.Connections.[New]("DTSFlatFile")

cn.DataSource = "c:\Text File.txt"

cn.ConnectionProperties.Item("Data Source").Value
= "c:\Text File.txt"


And for your second problem I cannot see what you are
erroring on as it
is unclear through my word wrapping

Dim oTask As DTS.Task
Dim oLookup As DTS.Lookup

Dim oCustomTask1 As DTS.DataPumpTask2
oTask = dtsImport.Tasks.New("DTSDataPumpTask")
oCustomTask1 = oTask.CustomTask




For your third problem what about

If pkg.Steps.Item(i).ExecutionResult =
DTS.DTSStepExecResult.DTSStepExecResult_Failure Then

End If



Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
www.konesans.com - for all your consultancy needs



.


Reply With Quote
  #4  
Old   
Darren Green
 
Posts: n/a

Default Re: DTS pkg to VB6 to VB.Net problem - 07-13-2004 , 03:07 PM



Quote:
oTask = goPackage.Tasks.New("DTSDataPumpTask")

on this line (Error #2) I get this complaint from the
compiler:

"Constructor call is valid only as the first statement in
an instance constructor"

Try-

oTask = CType(goPackage, DTS.Package).Tasks.New("DTSDataPumpTask")


Some more info on this topic-

Converting a DTS Package from Visual Basic 6.0 to Visual Basic .Net
(http://www.sqldts.com/default.aspx?264)

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server professionals
http://www.sqlpass.org



Reply With Quote
  #5  
Old   
Rich
 
Posts: n/a

Default Re: DTS pkg to VB6 to VB.Net problem - 07-13-2004 , 04:22 PM



Thanks. I'm starting to get the hang of this. I was able
to fix another constructor based error with your example.
This gave me the confidence to try Allan's suggestion of
adding .Item and .Value

oConnection.ConnectionProperties("Data Source")
to
oConnection.ConnectionProperties.Item("Data Source").Value

Thanks guys. I should be able to get this going in .Net
now. All I have left is a few more CTypes (so I can use
Option Strict On). Now I have the confidence.

Thanks for the refernce, too.
Rich


Quote:
-----Original Message-----

oTask = goPackage.Tasks.New("DTSDataPumpTask")

on this line (Error #2) I get this complaint from the
compiler:

"Constructor call is valid only as the first statement in
an instance constructor"


Try-

oTask = CType(goPackage, DTS.Package).Tasks.New
("DTSDataPumpTask")


Some more info on this topic-

Converting a DTS Package from Visual Basic 6.0 to Visual
Basic .Net
(http://www.sqldts.com/default.aspx?264)

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server
professionals
http://www.sqlpass.org

.


Reply With Quote
  #6  
Old   
Rich
 
Posts: n/a

Default Re: DTS pkg to VB6 to VB.Net problem - 07-13-2004 , 04:44 PM



Well, this is the last sub that I wasn't able to get, even
with the info at (http://www.sqldts.com/default.aspx?
264). They didn't have instructions for DTS.Steps. Here
is the sub I couldn't get:

-->oPackage.Steps(i).ExecutionResult =...

I tried CType(oPackage, DTS.Package).Steps... no go

Public Sub tracePackageError(ByVal oPackage As DTS.Package)
Dim ErrorCode As Long
Dim ErrorSource As String
Dim ErrorDescription As String
Dim ErrorHelpFile As String
Dim ErrorHelpContext As Long
Dim ErrorIDofInterfaceWithError As String
Dim i As Integer

For i = 1 To oPackage.Steps.Count
If oPackage.Steps(i).ExecutionResult = <--problem here
DTSStepExecResult.DTSStepExecResult_Failure Then
oPackage.Steps(i).GetExecutionErrorInfo(ErrorCode,
ErrorSource, ErrorDescription, ErrorHelpFile,
ErrorHelpContext, ErrorIDofInterfaceWithError)
MsgBox(oPackage.Steps(i).Name & " failed" & vbCrLf &
ErrorSource & vbCrLf & ErrorDescription)
End If
Next i

End Sub

I was able to get
DTSStepExecResult.DTSStepExecResult_Failure

by adding DTSStepExecResult. to DTSStepExecResult_Failure

I respectfully request one more hint (if I may) on the
DTS.Steps thing.

Thanks for all the help,
Rich

Quote:
-----Original Message-----

oTask = goPackage.Tasks.New("DTSDataPumpTask")

on this line (Error #2) I get this complaint from the
compiler:

"Constructor call is valid only as the first statement in
an instance constructor"


Try-

oTask = CType(goPackage, DTS.Package).Tasks.New
("DTSDataPumpTask")


Some more info on this topic-

Converting a DTS Package from Visual Basic 6.0 to Visual
Basic .Net
(http://www.sqldts.com/default.aspx?264)

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server
professionals
http://www.sqlpass.org

.


Reply With Quote
  #7  
Old   
Rich
 
Posts: n/a

Default Re: DTS pkg to VB6 to VB.Net problem - 07-13-2004 , 05:25 PM



Nevermind. I figured it out.

oPackage.Steps(i).ExecutionResult =...

to

oPackage.Steps.Item(i).ExecutionResult =...

Many Thanks again for all the help.

Rich


Quote:
-----Original Message-----
Well, this is the last sub that I wasn't able to get,
even
with the info at (http://www.sqldts.com/default.aspx?
264). They didn't have instructions for DTS.Steps. Here
is the sub I couldn't get:

-->oPackage.Steps(i).ExecutionResult =...

I tried CType(oPackage, DTS.Package).Steps... no go

Public Sub tracePackageError(ByVal oPackage As
DTS.Package)
Dim ErrorCode As Long
Dim ErrorSource As String
Dim ErrorDescription As String
Dim ErrorHelpFile As String
Dim ErrorHelpContext As Long
Dim ErrorIDofInterfaceWithError As String
Dim i As Integer

For i = 1 To oPackage.Steps.Count
If oPackage.Steps(i).ExecutionResult = <--problem here
DTSStepExecResult.DTSStepExecResult_Failure Then
oPackage.Steps(i).GetExecutionErrorInfo(ErrorCode,
ErrorSource, ErrorDescription, ErrorHelpFile,
ErrorHelpContext, ErrorIDofInterfaceWithError)
MsgBox(oPackage.Steps(i).Name & " failed" & vbCrLf &
ErrorSource & vbCrLf & ErrorDescription)
End If
Next i

End Sub

I was able to get
DTSStepExecResult.DTSStepExecResult_Failure

by adding DTSStepExecResult. to
DTSStepExecResult_Failure

I respectfully request one more hint (if I may) on the
DTS.Steps thing.

Thanks for all the help,
Rich

-----Original Message-----

oTask = goPackage.Tasks.New("DTSDataPumpTask")

on this line (Error #2) I get this complaint from the
compiler:

"Constructor call is valid only as the first statement
in
an instance constructor"


Try-

oTask = CType(goPackage, DTS.Package).Tasks.New
("DTSDataPumpTask")


Some more info on this topic-

Converting a DTS Package from Visual Basic 6.0 to Visual
Basic .Net
(http://www.sqldts.com/default.aspx?264)

--
Darren Green (SQL Server MVP)
DTS - http://www.sqldts.com

PASS - the definitive, global community for SQL Server
professionals
http://www.sqlpass.org

.

.


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