0

无法在 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;
}
4

1 回答 1

0

虽然绝对不是最佳答案,

    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。如果没有文件,则正常退出,否则通过控制流工作。

于 2021-05-06T17:47:20.517 回答