Alright, I definitely don't know what I'm doing 😉
I get values of 'System.__ComObject' for my variable instead of what I think I assigned.
In the script task from the Control Flow level I'm doing this to set it:
public void Main()
{
// Create a logical file object
System.IO.FileInfo theFile = new System.IO.FileInfo(Dts.Variables["FileName"].Value.ToString());
// update the user variable FullFilePath
//Dts.Variables["FullFilePath"].Value = Dts.Variables["FullName"].Value.ToString();
// If the file exists and is a txt file, then set the appropriate tableDestination and processFile.
if (theFile.Exists && theFile.Extension ==".txt")
{
//MessageBox.Show("Processing file " + Dts.Variables["Filename"].Value.ToString());
if (theFile.Name.Contains("ADV_") && theFile.Name.Contains("2TO3"))
{
//MessageBox.Show("Processing file " + Dts.Variables["Filename"].Value.ToString());
Dts.Variables["ProcessFile"].Value = true;
Dts.Variables["tableDestination"].Value = "CPM_Recon_ODJFS_ADV_2TO3";
}
and in the script component within the data flow, I do this to read it:
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
IDTSVariables100 vars = null;
this.VariableDispenser.LockOneForRead("tableDestination", ref vars);
string strVars = vars.ToString();
vars.Unlock();
this.VariableDispenser.LockOneForRead("FileName", ref vars);
string fileVars = vars.ToString();
vars.Unlock();
try
{
//log which table is being processed
logBuffer.AddRow();
logBuffer.status = "Processing " + fileVars + " to " + strVars;
//try to process the file
if( strVars.Equals("CPM_Recon_ODJFS_ADV_2TO3"))
{
string str = Row.Column0.ToString();
ADV2TO3Buffer.AddRow();
ADV2TO3Buffer.type = "ADV2TO3";
ADV2TO3Buffer.MEMID = str.Substring(0, 12);
ADV2TO3Buffer.NUM = Convert.ToInt16(str.Substring(19, 1));
ADV2TO3Buffer.DENOM = Convert.ToInt16(str.Substring(27, 1));
logBuffer.AddRow();
logBuffer.status = "TRUE: ADV2To3";
}
else //if (true == false)
{
//do something else
logBuffer.AddRow();
logBuffer.status = "FALSE: Not ADV2To3";
}
}
It never equals the value I want, the "CPM_Recon_ODJFS_ADV_2TO3", so it returns "FALSE: Not ADV2To3" and "Processing System.__ComObject to System.__ComObject"
Is that an obvious fix to anybody?
---------------------------------------------------------
How best to post your question[/url]
How to post performance problems[/url]
Tally Table:What it is and how it replaces a loop[/url]
"stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."