我试图根据计数更新数据库表中的列,但它会一直返回值0而不是递增。当用户点击批准按钮时,应使用此方法更新行号。这是我到目前为止所做的。
public void SetRequisitionStatus0(List <string> reqNumbers, List <string> item_no)
{
SqlConnection connection = new SqlConnection(connectionString);
SqlCommand command = new SqlCommand();
command.CommandText = "requisition_sp_setstatus0";
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@reqNumber", SqlDbType.VarChar);
command.Parameters.Add("@item_no", SqlDbType.VarChar);
//command.Parameters.Add("@ApprovedBy", SqlDbType.VarChar);
command.Parameters.Add("@approve_date", SqlDbType.DateTime).Value = DateTime.Now;
command.Parameters.Add("@line_num", SqlDbType.Int);
using (command.Connection = connection)
{
try
{
connection.Open();
for (int i = 0; i < reqNumbers.Count; i++)
{
command.Parameters["@reqNumber"].Value = reqNumbers[i];
command.Parameters["@item_no"].Value = item_no[i];
command.Parameters["@line_num"].Value = i;
command.ExecuteNonQuery();
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
connection.Close();
}
}
return;
}