Jamie
Jamie

Reputation: 483

Cannot apply equality in SQL Data Tools scripts "Operator '==' cannot be applied to operands of type 'bool'" (FIX)

Cannot apply equality in SQL Data Tools scripts.
Purpose: Establish a variable to use as a graceful exit when nothing needs to be done

ERRORS

"Operator '==' cannot be applied to operands of type 'bool'" 
Only assignment, call, increment, decrment, await, and new object expressions can be uses as statement

CODE:

String recfil=Dts.Variables["User::FolderPath"].Value.ToString() + Dts.Variables["User::RecfileName"0.Value.ToString();
int recfilExists=Convert.ToInt32(File.Exists(recfil));
bool goodRun = irecfilExists.Equals(1)
bool noRun = irecfilExists.Equals(0)

if (goodRun)
{
Dts.Variables["User::NothingToDo"].Value == goodRun;
Dts.TaskResult = (int)ScriptResults.Success;
}
else
{
Dts.Variables["User::NothingToDo"].Value == noRun;   
Dts.TaskResult = (int)ScriptResults.Failure;
}

Upvotes: 0

Views: 26

Answers (1)

Jamie
Jamie

Reputation: 483

While definitely not the best answer,

    if (goodRun || noRun)
      {
            if (goodRun)
            {
               Dts.Variables["User::FileCount"].Value = 1;
            }
            else
            {
               Dts.Variables["User::FileCount"].Value = 0;
            }
            Dts.TaskResult = (int)ScriptResults.Success;
      }  
   else
      {
           Dts.TaskResult = (int)ScriptResults.Failure;
      }

Then in the control flow, added choice function on Success which references the file count as one or zero. If no files, exit gracefully, otherwise work through the control flow.

Upvotes: 0

Related Questions