![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, I need some help. I've been doing a lot of reading but cannot seem to get over this error. My software: Win2000, SQL 2000, VB.Net I have a DTS package in SQL Serve that works fine. I want to use it in a VB.Net application. -1. I created a .bas file from the DTS designer. -2. I imported the Code into my .Net Solution, on a form in a Click event for a button. -3. I made refences to DTS, DTSCusTask, and DTSPump in the project. I get an error when it gets to the Task section. The error is: "An unhandled exception of type 'System.InvalidCastException' occurred in EOB.exe Additional information: QueryInterface for interface DTS.CustomTask failed." Here is the line of code highlighted when it breaks: oExecuteSQLTask2 = oTask.CustomTask I'll post all the code so it can read, and understood: Private Sub btnExec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExec.Click Dim goPackageOld As New DTS.Package() Dim goPackage As DTS.Package2 'Give the Packe2 the old Package properties also goPackage = goPackageOld 'Setup the Package goPackage.Name = "Import EOB Text File" goPackage.WriteCompletionStatusToNTEventLog = False goPackage.FailOnError = False goPackage.PackagePriorityClass = 2 goPackage.MaxConcurrentSteps = 4 goPackage.LineageOptions = 0 goPackage.UseTransaction = True goPackage.TransactionIsolationLevel = 4096 goPackage.AutoCommitTransaction = True goPackage.RepositoryMetadataOptions = 0 goPackage.UseOLEDBServiceComponents = True goPackage.LogToSQLServer = False goPackage.LogServerFlags = 0 goPackage.FailPackageOnLogFailure = False goPackage.ExplicitGlobalVariables = False goPackage.PackageType = 0 '----------------------------------------------------------------------- ' create package connection information '----------------------------------------------------------------------- Dim oConnection As DTS.Connection2 '------------- a new connection defined below. 'For security purposes, the password is never scripted oConnection = goPackage.Connections.New("SQLOLEDB") oConnection.Name = "EOB Database Conn" oConnection.ID = 2 oConnection.Reusable = True oConnection.ConnectImmediate = False oConnection.DataSource = "(local)" oConnection.ConnectionTimeout = 60 oConnection.Catalog = "EOB" oConnection.UseTrustedConnection = True oConnection.UseDSL = False 'If you have a password for this connection, please uncomment 'and add your password below. 'oConnection.Password = "<put the password here>" goPackage.Connections.Add(oConnection) oConnection = Nothing '--------------------------------------------------------------------------- ' Create package steps information ' **A step here is the Same as a Task in SQL ' **Data Transformation Designer ' ** Take notice that the Description of the Step is : Execute ' ** SQL Task: Delete Data ' ** "A SQL Task"--so don't get confused '--------------------------------------------------------------------------- Dim oStep As DTS.Step2 '------------- a new step defined below oStep = goPackage.Steps.New oStep.Name = "DTSStep_DTSExecuteSQLTask" oStep.Description = "Execute SQL Task: Delete Data" oStep.ExecutionStatus = 1 oStep.TaskName = "DTSTask_DTSExecuteSQLTask" oStep.CommitSuccess = False oStep.RollbackFailure = False oStep.ScriptLanguage = "VBScript" oStep.AddGlobalVariables = True oStep.RelativePriority = 3 oStep.CloseConnection = False oStep.ExecuteInMainThread = False oStep.IsPackageDSORowset = False oStep.JoinTransactionIfPresent = False oStep.DisableStep = False oStep.FailPackageOnError = False 'Add the Step to the Package goPackage.Steps.Add(oStep) oStep = Nothing '----------------------------------------------------------------------- ' Add the Functionality to the Task ' ** This is the Action that is Taken for the Step '----------------------------------------------------------------------- Dim oTask As DTS.Task Dim oExecuteSQLTask2 As DTS.ExecuteSQLTask2 'Create the Task asn then link the task to the Connections 'Dim oCustomTask2 As DTS.ExecuteSQLTask2 'The following line has been modified. The orginal line is: 'oTask = goPackage.Tasks.New("DTSExecuteSQLTask") oTask = CType(goPackage, DTS.Package2).Tasks.New("DTSExecuteSQLTask") oExecuteSQLTask2 = oTask.CustomTask oExecuteSQLTask2.Name = "DTSTask_DTSExecuteSQLTask" oExecuteSQLTask2.Description = "Execute SQL Task: Delete Data" oExecuteSQLTask2.SQLStatement = "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblEOB_Temp" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine1" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine2" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine3" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine4" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine5" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine6" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine7" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine8" oExecuteSQLTask2.ConnectionID = 2 oExecuteSQLTask2.CommandTimeout = 0 oExecuteSQLTask2.OutputAsRecordset = False 'Add the Task to the Package. goPackage.Tasks.Add(oTask) oExecuteSQLTask2 = Nothing oTask = Nothing '--------------------------------------------------------------------------- ' Save or execute package '--------------------------------------------------------------------------- 'goPackage.SaveToSQLServer "(local)", "sa", "" goPackage.Execute() goPackage.UnInitialize() 'to save a package instead of executing it, comment out the executing package line above and uncomment the saving package line goPackage = Nothing goPackageOld = Nothing End Sub All advice is welcome. I've been working on trying to Create a DTS appliction for a Week now and I'm crashing hard. Please help Thanks, rwiethorn |
#3
| |||
| |||
|
|
Are you coming across this error QueryInterface for interface DTS.CustomTask failed http://www.sqldts.com/default.aspx?6,222,286,0,1 -- ---------------------------- Allan Mitchell (Microsoft SQL Server MVP) MCSE,MCDBA www.SQLDTS.com I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "rwiethorn" <rwiethorn2002 (AT) yahoo (DOT) com> wrote in message news:553a0349.0307141247.3014ff83 (AT) posting (DOT) google.com... Hello, I need some help. I've been doing a lot of reading but cannot seem to get over this error. My software: Win2000, SQL 2000, VB.Net I have a DTS package in SQL Serve that works fine. I want to use it in a VB.Net application. -1. I created a .bas file from the DTS designer. -2. I imported the Code into my .Net Solution, on a form in a Click event for a button. -3. I made refences to DTS, DTSCusTask, and DTSPump in the project. I get an error when it gets to the Task section. The error is: "An unhandled exception of type 'System.InvalidCastException' occurred in EOB.exe Additional information: QueryInterface for interface DTS.CustomTask failed." Here is the line of code highlighted when it breaks: oExecuteSQLTask2 = oTask.CustomTask I'll post all the code so it can read, and understood: Private Sub btnExec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExec.Click Dim goPackageOld As New DTS.Package() Dim goPackage As DTS.Package2 'Give the Packe2 the old Package properties also goPackage = goPackageOld 'Setup the Package goPackage.Name = "Import EOB Text File" goPackage.WriteCompletionStatusToNTEventLog = False goPackage.FailOnError = False goPackage.PackagePriorityClass = 2 goPackage.MaxConcurrentSteps = 4 goPackage.LineageOptions = 0 goPackage.UseTransaction = True goPackage.TransactionIsolationLevel = 4096 goPackage.AutoCommitTransaction = True goPackage.RepositoryMetadataOptions = 0 goPackage.UseOLEDBServiceComponents = True goPackage.LogToSQLServer = False goPackage.LogServerFlags = 0 goPackage.FailPackageOnLogFailure = False goPackage.ExplicitGlobalVariables = False goPackage.PackageType = 0 '----------------------------------------------------------------------- ' create package connection information '----------------------------------------------------------------------- Dim oConnection As DTS.Connection2 '------------- a new connection defined below. 'For security purposes, the password is never scripted oConnection = goPackage.Connections.New("SQLOLEDB") oConnection.Name = "EOB Database Conn" oConnection.ID = 2 oConnection.Reusable = True oConnection.ConnectImmediate = False oConnection.DataSource = "(local)" oConnection.ConnectionTimeout = 60 oConnection.Catalog = "EOB" oConnection.UseTrustedConnection = True oConnection.UseDSL = False 'If you have a password for this connection, please uncomment 'and add your password below. 'oConnection.Password = "<put the password here>" goPackage.Connections.Add(oConnection) oConnection = Nothing '--------------------------------------------------------------------------- ' Create package steps information ' **A step here is the Same as a Task in SQL ' **Data Transformation Designer ' ** Take notice that the Description of the Step is : Execute ' ** SQL Task: Delete Data ' ** "A SQL Task"--so don't get confused '--------------------------------------------------------------------------- Dim oStep As DTS.Step2 '------------- a new step defined below oStep = goPackage.Steps.New oStep.Name = "DTSStep_DTSExecuteSQLTask" oStep.Description = "Execute SQL Task: Delete Data" oStep.ExecutionStatus = 1 oStep.TaskName = "DTSTask_DTSExecuteSQLTask" oStep.CommitSuccess = False oStep.RollbackFailure = False oStep.ScriptLanguage = "VBScript" oStep.AddGlobalVariables = True oStep.RelativePriority = 3 oStep.CloseConnection = False oStep.ExecuteInMainThread = False oStep.IsPackageDSORowset = False oStep.JoinTransactionIfPresent = False oStep.DisableStep = False oStep.FailPackageOnError = False 'Add the Step to the Package goPackage.Steps.Add(oStep) oStep = Nothing '----------------------------------------------------------------------- ' Add the Functionality to the Task ' ** This is the Action that is Taken for the Step '----------------------------------------------------------------------- Dim oTask As DTS.Task Dim oExecuteSQLTask2 As DTS.ExecuteSQLTask2 'Create the Task asn then link the task to the Connections 'Dim oCustomTask2 As DTS.ExecuteSQLTask2 'The following line has been modified. The orginal line is: 'oTask = goPackage.Tasks.New("DTSExecuteSQLTask") oTask = CType(goPackage, DTS.Package2).Tasks.New("DTSExecuteSQLTask") oExecuteSQLTask2 = oTask.CustomTask oExecuteSQLTask2.Name = "DTSTask_DTSExecuteSQLTask" oExecuteSQLTask2.Description = "Execute SQL Task: Delete Data" oExecuteSQLTask2.SQLStatement = "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblEOB_Temp" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine1" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine2" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine3" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine4" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine5" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine6" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine7" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine8" oExecuteSQLTask2.ConnectionID = 2 oExecuteSQLTask2.CommandTimeout = 0 oExecuteSQLTask2.OutputAsRecordset = False 'Add the Task to the Package. goPackage.Tasks.Add(oTask) oExecuteSQLTask2 = Nothing oTask = Nothing '--------------------------------------------------------------------------- ' Save or execute package '--------------------------------------------------------------------------- 'goPackage.SaveToSQLServer "(local)", "sa", "" goPackage.Execute() goPackage.UnInitialize() 'to save a package instead of executing it, comment out the executing package line above and uncomment the saving package line goPackage = Nothing goPackageOld = Nothing End Sub All advice is welcome. I've been working on trying to Create a DTS appliction for a Week now and I'm crashing hard. Please help Thanks, rwiethorn |
#4
| |||
| |||
|
|
It looks like it, here is the error quote: "An unhandled exception of type 'System.InvalidCastException' occurred in EOB.exe Additional information: QueryInterface for interface DTS.CustomTask failed." So looks like i need to check for SP versions. Were on SQL should I look for that? thanks rwiethorn "Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote Are you coming across this error QueryInterface for interface DTS.CustomTask failed http://www.sqldts.com/default.aspx?6,222,286,0,1 -- ---------------------------- Allan Mitchell (Microsoft SQL Server MVP) MCSE,MCDBA www.SQLDTS.com I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "rwiethorn" <rwiethorn2002 (AT) yahoo (DOT) com> wrote in message news:553a0349.0307141247.3014ff83 (AT) posting (DOT) google.com... Hello, I need some help. I've been doing a lot of reading but cannot seem to get over this error. My software: Win2000, SQL 2000, VB.Net I have a DTS package in SQL Serve that works fine. I want to use it in a VB.Net application. -1. I created a .bas file from the DTS designer. -2. I imported the Code into my .Net Solution, on a form in a Click event for a button. -3. I made refences to DTS, DTSCusTask, and DTSPump in the project. I get an error when it gets to the Task section. The error is: "An unhandled exception of type 'System.InvalidCastException' occurred in EOB.exe Additional information: QueryInterface for interface DTS.CustomTask failed." Here is the line of code highlighted when it breaks: oExecuteSQLTask2 = oTask.CustomTask I'll post all the code so it can read, and understood: Private Sub btnExec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExec.Click Dim goPackageOld As New DTS.Package() Dim goPackage As DTS.Package2 'Give the Packe2 the old Package properties also goPackage = goPackageOld 'Setup the Package goPackage.Name = "Import EOB Text File" goPackage.WriteCompletionStatusToNTEventLog = False goPackage.FailOnError = False goPackage.PackagePriorityClass = 2 goPackage.MaxConcurrentSteps = 4 goPackage.LineageOptions = 0 goPackage.UseTransaction = True goPackage.TransactionIsolationLevel = 4096 goPackage.AutoCommitTransaction = True goPackage.RepositoryMetadataOptions = 0 goPackage.UseOLEDBServiceComponents = True goPackage.LogToSQLServer = False goPackage.LogServerFlags = 0 goPackage.FailPackageOnLogFailure = False goPackage.ExplicitGlobalVariables = False goPackage.PackageType = 0 '----------------------------------------------------------------------- ' create package connection information '----------------------------------------------------------------------- Dim oConnection As DTS.Connection2 '------------- a new connection defined below. 'For security purposes, the password is never scripted oConnection = goPackage.Connections.New("SQLOLEDB") oConnection.Name = "EOB Database Conn" oConnection.ID = 2 oConnection.Reusable = True oConnection.ConnectImmediate = False oConnection.DataSource = "(local)" oConnection.ConnectionTimeout = 60 oConnection.Catalog = "EOB" oConnection.UseTrustedConnection = True oConnection.UseDSL = False 'If you have a password for this connection, please uncomment 'and add your password below. 'oConnection.Password = "<put the password here>" goPackage.Connections.Add(oConnection) oConnection = Nothing '--------------------------------------------------------------------------- ' Create package steps information ' **A step here is the Same as a Task in SQL ' **Data Transformation Designer ' ** Take notice that the Description of the Step is : Execute ' ** SQL Task: Delete Data ' ** "A SQL Task"--so don't get confused '--------------------------------------------------------------------------- Dim oStep As DTS.Step2 '------------- a new step defined below oStep = goPackage.Steps.New oStep.Name = "DTSStep_DTSExecuteSQLTask" oStep.Description = "Execute SQL Task: Delete Data" oStep.ExecutionStatus = 1 oStep.TaskName = "DTSTask_DTSExecuteSQLTask" oStep.CommitSuccess = False oStep.RollbackFailure = False oStep.ScriptLanguage = "VBScript" oStep.AddGlobalVariables = True oStep.RelativePriority = 3 oStep.CloseConnection = False oStep.ExecuteInMainThread = False oStep.IsPackageDSORowset = False oStep.JoinTransactionIfPresent = False oStep.DisableStep = False oStep.FailPackageOnError = False 'Add the Step to the Package goPackage.Steps.Add(oStep) oStep = Nothing '----------------------------------------------------------------------- ' Add the Functionality to the Task ' ** This is the Action that is Taken for the Step '----------------------------------------------------------------------- Dim oTask As DTS.Task Dim oExecuteSQLTask2 As DTS.ExecuteSQLTask2 'Create the Task asn then link the task to the Connections 'Dim oCustomTask2 As DTS.ExecuteSQLTask2 'The following line has been modified. The orginal line is: 'oTask = goPackage.Tasks.New("DTSExecuteSQLTask") oTask = CType(goPackage, DTS.Package2).Tasks.New("DTSExecuteSQLTask") oExecuteSQLTask2 = oTask.CustomTask oExecuteSQLTask2.Name = "DTSTask_DTSExecuteSQLTask" oExecuteSQLTask2.Description = "Execute SQL Task: Delete Data" oExecuteSQLTask2.SQLStatement = "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblEOB_Temp" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine1" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine2" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine3" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine4" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine5" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine6" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine7" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine8" oExecuteSQLTask2.ConnectionID = 2 oExecuteSQLTask2.CommandTimeout = 0 oExecuteSQLTask2.OutputAsRecordset = False 'Add the Task to the Package. goPackage.Tasks.Add(oTask) oExecuteSQLTask2 = Nothing oTask = Nothing '--------------------------------------------------------------------------- ' Save or execute package '--------------------------------------------------------------------------- 'goPackage.SaveToSQLServer "(local)", "sa", "" goPackage.Execute() goPackage.UnInitialize() 'to save a package instead of executing it, comment out the executing package line above and uncomment the saving package line goPackage = Nothing goPackageOld = Nothing End Sub All advice is welcome. I've been working on trying to Create a DTS appliction for a Week now and I'm crashing hard. Please help Thanks, rwiethorn |
#5
| |||
| |||
|
|
Are you coming across this error QueryInterface for interface DTS.CustomTask failed http://www.sqldts.com/default.aspx?6,222,286,0,1 -- ---------------------------- Allan Mitchell (Microsoft SQL Server MVP) MCSE,MCDBA www.SQLDTS.com I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "rwiethorn" <rwiethorn2002 (AT) yahoo (DOT) com> wrote in message news:553a0349.0307141247.3014ff83 (AT) posting (DOT) google.com... Hello, I need some help. I've been doing a lot of reading but cannot seem to get over this error. My software: Win2000, SQL 2000, VB.Net I have a DTS package in SQL Serve that works fine. I want to use it in a VB.Net application. -1. I created a .bas file from the DTS designer. -2. I imported the Code into my .Net Solution, on a form in a Click event for a button. -3. I made refences to DTS, DTSCusTask, and DTSPump in the project. I get an error when it gets to the Task section. The error is: "An unhandled exception of type 'System.InvalidCastException' occurred in EOB.exe Additional information: QueryInterface for interface DTS.CustomTask failed." Here is the line of code highlighted when it breaks: oExecuteSQLTask2 = oTask.CustomTask I'll post all the code so it can read, and understood: Private Sub btnExec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExec.Click Dim goPackageOld As New DTS.Package() Dim goPackage As DTS.Package2 'Give the Packe2 the old Package properties also goPackage = goPackageOld 'Setup the Package goPackage.Name = "Import EOB Text File" goPackage.WriteCompletionStatusToNTEventLog = False goPackage.FailOnError = False goPackage.PackagePriorityClass = 2 goPackage.MaxConcurrentSteps = 4 goPackage.LineageOptions = 0 goPackage.UseTransaction = True goPackage.TransactionIsolationLevel = 4096 goPackage.AutoCommitTransaction = True goPackage.RepositoryMetadataOptions = 0 goPackage.UseOLEDBServiceComponents = True goPackage.LogToSQLServer = False goPackage.LogServerFlags = 0 goPackage.FailPackageOnLogFailure = False goPackage.ExplicitGlobalVariables = False goPackage.PackageType = 0 '----------------------------------------------------------------------- ' create package connection information '----------------------------------------------------------------------- Dim oConnection As DTS.Connection2 '------------- a new connection defined below. 'For security purposes, the password is never scripted oConnection = goPackage.Connections.New("SQLOLEDB") oConnection.Name = "EOB Database Conn" oConnection.ID = 2 oConnection.Reusable = True oConnection.ConnectImmediate = False oConnection.DataSource = "(local)" oConnection.ConnectionTimeout = 60 oConnection.Catalog = "EOB" oConnection.UseTrustedConnection = True oConnection.UseDSL = False 'If you have a password for this connection, please uncomment 'and add your password below. 'oConnection.Password = "<put the password here>" goPackage.Connections.Add(oConnection) oConnection = Nothing '--------------------------------------------------------------------------- ' Create package steps information ' **A step here is the Same as a Task in SQL ' **Data Transformation Designer ' ** Take notice that the Description of the Step is : Execute ' ** SQL Task: Delete Data ' ** "A SQL Task"--so don't get confused '--------------------------------------------------------------------------- Dim oStep As DTS.Step2 '------------- a new step defined below oStep = goPackage.Steps.New oStep.Name = "DTSStep_DTSExecuteSQLTask" oStep.Description = "Execute SQL Task: Delete Data" oStep.ExecutionStatus = 1 oStep.TaskName = "DTSTask_DTSExecuteSQLTask" oStep.CommitSuccess = False oStep.RollbackFailure = False oStep.ScriptLanguage = "VBScript" oStep.AddGlobalVariables = True oStep.RelativePriority = 3 oStep.CloseConnection = False oStep.ExecuteInMainThread = False oStep.IsPackageDSORowset = False oStep.JoinTransactionIfPresent = False oStep.DisableStep = False oStep.FailPackageOnError = False 'Add the Step to the Package goPackage.Steps.Add(oStep) oStep = Nothing '----------------------------------------------------------------------- ' Add the Functionality to the Task ' ** This is the Action that is Taken for the Step '----------------------------------------------------------------------- Dim oTask As DTS.Task Dim oExecuteSQLTask2 As DTS.ExecuteSQLTask2 'Create the Task asn then link the task to the Connections 'Dim oCustomTask2 As DTS.ExecuteSQLTask2 'The following line has been modified. The orginal line is: 'oTask = goPackage.Tasks.New("DTSExecuteSQLTask") oTask = CType(goPackage, DTS.Package2).Tasks.New("DTSExecuteSQLTask") oExecuteSQLTask2 = oTask.CustomTask oExecuteSQLTask2.Name = "DTSTask_DTSExecuteSQLTask" oExecuteSQLTask2.Description = "Execute SQL Task: Delete Data" oExecuteSQLTask2.SQLStatement = "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblEOB_Temp" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine1" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine2" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine3" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine4" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine5" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine6" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine7" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine8" oExecuteSQLTask2.ConnectionID = 2 oExecuteSQLTask2.CommandTimeout = 0 oExecuteSQLTask2.OutputAsRecordset = False 'Add the Task to the Package. goPackage.Tasks.Add(oTask) oExecuteSQLTask2 = Nothing oTask = Nothing '--------------------------------------------------------------------------- ' Save or execute package '--------------------------------------------------------------------------- 'goPackage.SaveToSQLServer "(local)", "sa", "" goPackage.Execute() goPackage.UnInitialize() 'to save a package instead of executing it, comment out the executing package line above and uncomment the saving package line goPackage = Nothing goPackageOld = Nothing End Sub All advice is welcome. I've been working on trying to Create a DTS appliction for a Week now and I'm crashing hard. Please help Thanks, rwiethorn |
#6
| |||
| |||
|
|
I looked up the verison I have and it says SP1(oops). So I preceded to download the latest, SP3a. I tried to apply it, but it doesn't seem to take. When I rerun the querries: SELECT @@VERSION Select SERVERPROPERTY('ProductVersion') SELECT SERVERPROPERTY('ProductLevel') The output still says its SP1!!! But,when I go to Control Panle>Add/Remove Programs, and Select MS SQL Server, and Click on Support info, it says I have version 8.00.761!!! Any ideas whats happening here? Another note: I cannot use the downloadable version of the of the update for the Desktop Engine (MSDE 2000) SP3a because it was installed from sqltrun02.msi thanks for the help, rwiethorn "Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote Are you coming across this error QueryInterface for interface DTS.CustomTask failed http://www.sqldts.com/default.aspx?6,222,286,0,1 -- ---------------------------- Allan Mitchell (Microsoft SQL Server MVP) MCSE,MCDBA www.SQLDTS.com I support PASS - the definitive, global community for SQL Server professionals - http://www.sqlpass.org "rwiethorn" <rwiethorn2002 (AT) yahoo (DOT) com> wrote in message news:553a0349.0307141247.3014ff83 (AT) posting (DOT) google.com... Hello, I need some help. I've been doing a lot of reading but cannot seem to get over this error. My software: Win2000, SQL 2000, VB.Net I have a DTS package in SQL Serve that works fine. I want to use it in a VB.Net application. -1. I created a .bas file from the DTS designer. -2. I imported the Code into my .Net Solution, on a form in a Click event for a button. -3. I made refences to DTS, DTSCusTask, and DTSPump in the project. I get an error when it gets to the Task section. The error is: "An unhandled exception of type 'System.InvalidCastException' occurred in EOB.exe Additional information: QueryInterface for interface DTS.CustomTask failed." Here is the line of code highlighted when it breaks: oExecuteSQLTask2 = oTask.CustomTask I'll post all the code so it can read, and understood: Private Sub btnExec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExec.Click Dim goPackageOld As New DTS.Package() Dim goPackage As DTS.Package2 'Give the Packe2 the old Package properties also goPackage = goPackageOld 'Setup the Package goPackage.Name = "Import EOB Text File" goPackage.WriteCompletionStatusToNTEventLog = False goPackage.FailOnError = False goPackage.PackagePriorityClass = 2 goPackage.MaxConcurrentSteps = 4 goPackage.LineageOptions = 0 goPackage.UseTransaction = True goPackage.TransactionIsolationLevel = 4096 goPackage.AutoCommitTransaction = True goPackage.RepositoryMetadataOptions = 0 goPackage.UseOLEDBServiceComponents = True goPackage.LogToSQLServer = False goPackage.LogServerFlags = 0 goPackage.FailPackageOnLogFailure = False goPackage.ExplicitGlobalVariables = False goPackage.PackageType = 0 '----------------------------------------------------------------------- ' create package connection information '----------------------------------------------------------------------- Dim oConnection As DTS.Connection2 '------------- a new connection defined below. 'For security purposes, the password is never scripted oConnection = goPackage.Connections.New("SQLOLEDB") oConnection.Name = "EOB Database Conn" oConnection.ID = 2 oConnection.Reusable = True oConnection.ConnectImmediate = False oConnection.DataSource = "(local)" oConnection.ConnectionTimeout = 60 oConnection.Catalog = "EOB" oConnection.UseTrustedConnection = True oConnection.UseDSL = False 'If you have a password for this connection, please uncomment 'and add your password below. 'oConnection.Password = "<put the password here>" goPackage.Connections.Add(oConnection) oConnection = Nothing '--------------------------------------------------------------------------- ' Create package steps information ' **A step here is the Same as a Task in SQL ' **Data Transformation Designer ' ** Take notice that the Description of the Step is : Execute ' ** SQL Task: Delete Data ' ** "A SQL Task"--so don't get confused '--------------------------------------------------------------------------- Dim oStep As DTS.Step2 '------------- a new step defined below oStep = goPackage.Steps.New oStep.Name = "DTSStep_DTSExecuteSQLTask" oStep.Description = "Execute SQL Task: Delete Data" oStep.ExecutionStatus = 1 oStep.TaskName = "DTSTask_DTSExecuteSQLTask" oStep.CommitSuccess = False oStep.RollbackFailure = False oStep.ScriptLanguage = "VBScript" oStep.AddGlobalVariables = True oStep.RelativePriority = 3 oStep.CloseConnection = False oStep.ExecuteInMainThread = False oStep.IsPackageDSORowset = False oStep.JoinTransactionIfPresent = False oStep.DisableStep = False oStep.FailPackageOnError = False 'Add the Step to the Package goPackage.Steps.Add(oStep) oStep = Nothing '----------------------------------------------------------------------- ' Add the Functionality to the Task ' ** This is the Action that is Taken for the Step '----------------------------------------------------------------------- Dim oTask As DTS.Task Dim oExecuteSQLTask2 As DTS.ExecuteSQLTask2 'Create the Task asn then link the task to the Connections 'Dim oCustomTask2 As DTS.ExecuteSQLTask2 'The following line has been modified. The orginal line is: 'oTask = goPackage.Tasks.New("DTSExecuteSQLTask") oTask = CType(goPackage, DTS.Package2).Tasks.New("DTSExecuteSQLTask") oExecuteSQLTask2 = oTask.CustomTask oExecuteSQLTask2.Name = "DTSTask_DTSExecuteSQLTask" oExecuteSQLTask2.Description = "Execute SQL Task: Delete Data" oExecuteSQLTask2.SQLStatement = "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblEOB_Temp" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine1" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine2" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine3" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine4" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine5" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine6" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine7" & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "DELETE " & vbCrLf oExecuteSQLTask2.SQLStatement = oExecuteSQLTask2.SQLStatement & "FROM tblLine8" oExecuteSQLTask2.ConnectionID = 2 oExecuteSQLTask2.CommandTimeout = 0 oExecuteSQLTask2.OutputAsRecordset = False 'Add the Task to the Package. goPackage.Tasks.Add(oTask) oExecuteSQLTask2 = Nothing oTask = Nothing '--------------------------------------------------------------------------- ' Save or execute package '--------------------------------------------------------------------------- 'goPackage.SaveToSQLServer "(local)", "sa", "" goPackage.Execute() goPackage.UnInitialize() 'to save a package instead of executing it, comment out the executing package line above and uncomment the saving package line goPackage = Nothing goPackageOld = Nothing End Sub All advice is welcome. I've been working on trying to Create a DTS appliction for a Week now and I'm crashing hard. Please help Thanks, rwiethorn |
![]() |
| Thread Tools | |
| Display Modes | |
| |