Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8527743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:38:31+00:00 2026-06-11T08:38:31+00:00

How would one be able to use a TaskHost object within C# (I use

  • 0

How would one be able to use a TaskHost object within C# (I use it inside an SSIS scripting task, but this should apply to C# in general as well) and deal with tables that are not in the “dbo” schema?

I have written code that basically connects to a source and a destination database, and then is supposed to bring across specific tables (inside a loop) one by one, both the table-schemas and the data.

On my localhost, this works just peachy, but at my client, the supplier is using schemas; not something we took into account originally, and this is giving me some trouble.

I have tried using the “SchemasList” property of the TaskHost object, but keep running into the same error:

? child.Errors[0]
{Microsoft.SqlServer.Dts.Runtime.DtsError}
    base {Microsoft.SqlServer.Dts.Runtime.DtsObject}: {Microsoft.SqlServer.Dts.Runtime.DtsError}
    Description: "Table \"[theSchema].[theTable]\" does not exist at the    source.\r\n"
ErrorCode: -1073548445
HelpContext: 0
HelpFile: ""
IDOfInterfaceWithError: "{B6F6D221-FC27-4F71-B5A0-597583986C28}"
Source: "{D6DF0C1F-0AC8-4748-836C-BEF052454AEE}"
SubComponent: "Transfer SQL Server Objects Task"
TimeStamp: {16-07-2012 13:41:43}

Here’s the code:

if (Dts.Variables["tableName"].Value.ToString() != "0") {
        string tableName;
        tableName = Dts.Variables["tableName"].Value.ToString();

        // Add a child package 
        Package child = new Package();

        child.Name = tableName;
        Executable moveTable = child.Executables.Add("STOCK:TransferSQLServerObjectsTask");
        TaskHost moveTableTask = (TaskHost)moveTable;

        // Set properties for the task
        moveTableTask.Properties["CopyAllObjects"].SetValue(moveTableTask, false);
        moveTableTask.Properties["CopyAllTables"].SetValue(moveTableTask, false);
        moveTableTask.Properties["CopySchema"].SetValue(moveTableTask, true);
        moveTableTask.Properties["DropObjectsFirst"].SetValue(moveTableTask, true);
        moveTableTask.Properties["CopyData"].SetValue(moveTableTask, true);

        // Set schemas
        //StringCollection schemas = new StringCollection();
        //String[] schemaList = new String[] {"[theSchema].[" + tableName + "]"};
        //schemas.AddRange(schemaList);
        //moveTableTask.Properties["SchemasList"].SetValue(moveTableTask, schemas);

        // Set tablenames
        StringCollection tables = new StringCollection();
        tables.Add(tableName);
        moveTableTask.Properties["TablesList"].SetValue(moveTableTask, tables);

        // Set up connections
        ConnectionManager source;
        ConnectionManager destination;

        source = child.Connections.Add("SMOServer");
        source.ConnectionString = "SqlServerName=*****;UseWindowsAuthentication=False;UserName=*****;Password=*****;";
        source.Name = "Source";

        destination = child.Connections.Add("SMOServer");
        destination.ConnectionString = "SqlServerName=*****;Persist Security Info=True;Password=*****;USER ID=*****;Initial Catalog=*****";
        destination.Name = "Destination";
        moveTableTask.Properties["SourceConnection"].SetValue(moveTableTask, "Source");
        moveTableTask.Properties["SourceDatabase"].SetValue(moveTableTask, "*****");
        moveTableTask.Properties["DestinationConnection"].SetValue(moveTableTask, "Destination");
        moveTableTask.Properties["DestinationDatabase"].SetValue(moveTableTask, "*****");

        child.Execute();

        child.Dispose();

As you can see, there is a commented bit which was an attempt to see if I could add the schema that way. Another option I tried was using the CopyAllSchemas property, but that also did nothing.

I also tried adding the schema in the line of code where the tablename is added to the tables stringcollection, but that yields the same error, regardless of using square brackets ([]) or not. It seems the TaskHost by default only accepts tables in the “dbo” schema, unless I am missing something.

Does anyone have any idea on how I could get the TaskHost to handle the database schema?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:38:32+00:00Added an answer on June 11, 2026 at 8:38 am

    As it turns out, the tables were not tables, but views.Using a combination of a Views collection, and some additional tweakings with the schemas I managed to get things to work 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm thinking .one would be of use in this situation? but i'm not sure
I'm wondering if MSAA is COM-based, then one should be able to use CreateObject(Accessibility)
I have following and would like to be able to use one function only
Under what scenarios would one want to use public async Task AsyncMethod(int num) instead
I would like to be able to swap one table partition for another, just
I would like to be able to merge two files into one during configure
Why would one use realloc() function to resize an dynamically allocated array rather than
Why would one use func( const Class &value ) rather than just func( Class
I would like to be able to use Spring using setter injection into Scala
According to the user guide , I should be able to use <url></url> in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.