Reputation: 362
Trying to automate a process that is currently two steps. First, we have an app in (VS 2010) C# that pulls down a price catalog from a vendor, massages the data and creates a .txt file. Second, we have a SSIS project (VS 2008) that empties a table in the (SQL Server 2005) database and refills it from the .txt file.
I'm trying to combine these steps by calling the SSIS project from the app. I'm open to suggestions if there is a better way to get the massaged data to the database.
The method I'm using is here:
private static void UpdateVendorTable()
{
string pkgLocation;
Package pkg;
Application app;
DTSExecResult pkgResults;
pkgLocation = appConfig.Default.DataSSIS; // C:\Projects\Vendor\vendor.dtsx
app = new Application();
pkg = app.LoadPackage(pkgLocation, null);
pkgResults = pkg.Execute();
}
However, I get back an error shown below when the "pkgLocation = appConfig.Default.DataSSIS;" line is reached.
The package failed to load due to error 0xC0011008 "Error loading from XML. No further detailed error information can be specified for this problem because no Events object was passed where detailed error information can be stored.". This occurs when CPackage::LoadFromXML fails. This exception has an InnerException: System.Runtime.InteropServices.COMException (0xC0011008): The package failed to load due to error 0xC0011008 "Error loading from XML. No further detailed error information can be specified for this problem because no Events object was passed where detailed error information can be stored.". This occurs when CPackage::LoadFromXML fails.
at Microsoft.SqlServer.Dts.Runtime.Wrapper.ApplicationClass.LoadPackage(String FileName, Boolean loadNeutral, IDTSEvents90 pEvents) at Microsoft.SqlServer.Dts.Runtime.Application.LoadPackage(String fileName, IDTSEvents events, Boolean loadNeutral)
Upvotes: 0
Views: 1513
Reputation: 362
The answer I eventually settled on was "Use SqlBulkCopy instead of SSIS." I had already created objects with all the data and so it made sense to just bulk copy to the database rather than write to a text file that the SSIS would use to update the database.
I found this great article http://blogs.msdn.com/b/nikhilsi/archive/2008/06/11/bulk-insert-into-sql-from-c-app.aspx that walked through all the steps and it worked wonderfully.
Upvotes: 1