The only way i've been able to do this is using a Script Component Transfor one row at a time to get the ids. Below is an example of what i do importing products from our ERP system.
I get one id for the product table and three id's for the productprogram. Before i get to the script component i use a derived column transform to add the id columns to each row. After i have the ids i then use an OLE DB Destination to insert into the slx db.
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
//create connection
using (OleDbConnection conn = new OleDbConnection("Provider=SLXOLEDB.1ersist Security Info=Trueassword=passwordUser ID=admin;Initial Catalog=slxDB;Data Source=slxServer;"))
{
conn.Open();
//get product id
using (OleDbCommand cmd = new OleDbCommand(String.Format("slx_DBIDs('{0}', {1})", "PRODUCT", 1), conn))
{
Row.PRODUCTID = cmd.ExecuteScalar().ToString();
}
//get program ids?
using (OleDbCommand cmd = new OleDbCommand(String.Format("slx_DBIDs('{0}', {1})", "PRODUCTPROGRAM", 3), conn))
{
using (OleDbDataReader dr = cmd.ExecuteReader())
{
List<string> programIds = new List<string>();
while (dr.Read())
{
programIds.Add(dr[0].ToString());
}
Row.RetailId = programIds[0];
Row.MSRPId = programIds[1];
Row.WholeSaleId = programIds[2];
}
}
}
} |