Соединение с БД есть, запрос рабочий, таблица в той БД есть, всё для подключения к БД и отправке запроса настроено правильно, как я понимаю. Но почему я не могу подставить значение переменной в запрос, что делаю не так?
добавлено позже:
Решил временно эту проблему так: в скрипте просто динамически генерирую запрос, все параметры в нём подставляю прямо в текст запроса. Так заработало.
private const string NotifyManagerTimestampName = "NotifyManagerTimestamp";
private const string SqlNotifyManagerTimestamp = "SqlNotifyManagerTimestamp";
private const string SqlNotifyManagerPattern = @"UPDATE DatetimeStamp SET STAMP = CAST({0} AS DATETIME2) WHERE NAME = 'SsisTestManager';";
/// <summary>
/// This method is called when this script task executes in the control flow.
/// Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
/// To open Help, press F1.
/// </summary>
public void Main()
{
try
{
DateTime now = DateTime.Now;
string nowParam = "'" + now.Year + now.Month.ToString("00") + now.Day.ToString("00") + "'";
string result = string.Format(SqlNotifyManagerPattern, nowParam);
Dts.Variables[NotifyManagerTimestampName].Value = now;
Dts.Variables[SqlNotifyManagerTimestamp].Value = result;
Dts.TaskResult = (int)ScriptResults.Success;
}
catch (Exception)
{
Dts.TaskResult = (int)ScriptResults.Failure;
}
}
конец.
Запрос, который использую в "
Задача "Выполнение SQL"UPDATE DatetimeStamp SET STAMP = CAST([NotifyManagerTimestamp] AS DATETIME2)
WHERE NAME = 'SsisTestManager';



- Задача Задача "Выполнение SQL":
Начата проверка данных
Проверка данных завершена
[Задача "Выполнение SQL"] Ошибка: Executing the query "UPDATE DatetimeStamp SET STAMP = CAST([NotifyManag..." failed with the following error: "Invalid column name 'NotifyManagerTimestamp'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Не удалось выполнить задачу Задача "Выполнение SQL"