基于SSIS开发--创建OLEDB源组件(二)
创建OLEDB源组件
// Create and configure an OLE DB source component.
IDTSComponentMetaData100 source = dataFlowTask.ComponentMetaDataCollection.New();
source.ComponentClassID = "DTSAdapter.OleDbSource";
// Create the design-time instance of the source.
CManagedComponentWrapper srcDesignTime = source.Instantiate();
// The ProvideComponentProperties method creates a default output.
srcDesignTime.ProvideComponentProperties();
// Assign the connection manager.
source.RuntimeConnectionCollection[0].ConnectionManager = DtsConvert.GetExtendedInterface(conMgr);
source.RuntimeConnectionCollection[0].ConnectionManagerID = conMgr.ID;
// Set the custom properties of the source.
//srcDesignTime.SetComponentProperty("AccessMode", 2);
//srcDesignTime.SetComponentProperty("SqlCommand", "Select * from sqldb");
srcDesignTime.SetComponentProperty("AccessMode", 0);
srcDesignTime.SetComponentProperty("OpenRowset", "\"dbo\".\"test\"");
// Connect to the data source,
// and then update the metadata for the source.
srcDesignTime.AcquireConnections(null);
srcDesignTime.ReinitializeMetaData();
//srcDesignTime.ReleaseConnections();

浙公网安备 33010602011771号