Ich verwende eine gespeicherte Prozedur, um eine Tabelle zu aktualisieren, wenn der Benutzer auf Genehmigen klickt, aber ich bekomme die Nachricht, dass es erfolgreich genehmigt wurde, aber die Tabelle wurde nicht aktualisiert.Update-Tabelle von der Webseite
Aktualisieren Ich bin jetzt nur in der Lage, ein Element zu aktualisieren; Selbst wenn ich mehr als ein Element auswähle, wird nur eines aktualisiert.
Stored Procedure
Update RequisitionItem
set [status] = 0,
[approve_date] = @approve_date
--[ApprovedBy][email protected]
where [status]=-1 and [email protected] and [email protected]_no
Methode
public void SetRequisitionStatus0(List <string> reqNumber,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;
using (command.Connection = connection)
{
try
{
connection.Open();
foreach (var item in reqNumbers)
{
command.Parameters["@reqNumber"].Value = item;
foreach (var item1 in item_no)
{
command.Parameters["@item_no"].Value = item1;
}
command.ExecuteNonQuery();
}
}
finally
{
connection.Close();
}
}
return;
}