SQL Server参数“未提供”;-但它是
本文关键字:未提供 参数 Server SQL | 更新日期: 2023-09-27 17:49:38
考虑下面的代码....为什么没有告诉我在尝试执行存储过程时未设置@PI_CDID参数值?
Console.WriteLine("Database Opened!");
SqlCommand cmd = new SqlCommand("P_IOU_Track", conn);
cmd.Parameters.Add(new SqlParameter("@PI_CDID", ICDID)); // parameter is added here
cmd.Parameters.Add(new SqlParameter("@PI_Title", ITitle));
cmd.Parameters.Add(new SqlParameter("@PI_Duration", IDuration));
cmd.Parameters.Add(new SqlParameter("@PI_CDNo", ICDNo));
cmd.Parameters.Add(new SqlParameter("@PI_TNo", ITNo));
foreach (SqlParameter p in cmd.Parameters )
{
Console.WriteLine("Parameter , {0} , Value --> {1} ",p.ParameterName, p.Value.ToString());
}
// Add output param
SqlParameter NextTID = new SqlParameter("@PO_NextTID", SqlDbType.BigInt);
NextTID.Direction = ParameterDirection.Output;
cmd.Parameters.Add(NextTID);
// Execute procedure
cmd.ExecuteNonQuery();
您忘记了cmd.CommandType = CommandType.StoredProcedure