0
存儲過程無法執行。任何人都可以請告訴我並指出我愚蠢的錯誤?存儲過程無法到達
,我得到的錯誤信息是
操作無效。關閉連接
代碼:
public void Update(RepliesBAL RPBAL)
{
using (SqlConnection connection = new SqlConnection(@"Data Source=19NNZP;Initial Catalog=ivr;Persist Security Info=True;User ID=sa;Password=sa"))
{
SqlCommand command = new SqlCommand();
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "dbo.fax_UpdateFaxReply";
command.Parameters.Add("@uid", SqlDbType.VarChar, 50).Value = RPBAL.UlyssesID ;
SqlTransaction transaction;
transaction = connection.BeginTransaction("SampleTransaction");
command.Connection = connection;
command.Transaction = transaction;
try
{
connection.Open();
command.ExecuteNonQuery();
Console.WriteLine("OK");
}
catch (Exception ex)
{
Console.WriteLine("Commit Exception Type: {0}", ex.GetType());
Console.WriteLine(" Message: {0}", ex.Message);
try
{
transaction.Rollback();
}
catch (Exception ex2)
{
Console.WriteLine("Rollback Exception Type: {0}", ex2.GetType());
Console.WriteLine(" Message: {0}", ex2.Message);
throw new Exception(ex.Message);
}
}
}
}
您是否嘗試使用相同的登錄名和參數直接運行SP? '@ ulyssesId'參數是什麼類型?是否有其他參數 - 特別是必需的參數? – Oded 2012-08-05 10:32:28
是的,通過使用相同登錄憑證直接運行sp沒有問題。只有一個參數,它是nvarchar(50)。這是錯誤消息,我得到了「操作無效,連接已關閉」。 – 2012-08-05 10:34:50