无法在 SQL Data Tools 脚本中应用相等性“运算符 '==' 不能应用于类型为 'bool' 的操作数”

问题描述

不能在 sql Data Tools 脚本中应用相等性
目的:建立一个变量,在不需要做任何事情时作为优雅退出使用

错误

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

代码

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;
}

解决方法

虽然绝对不是最佳答案,

    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;
      }

然后在控制流中,在 Success 上添加选择函数,将文件计数引用为 1 或 0。如果没有文件,请正常退出,否则执行控制流程。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...