问题描述:
C#调用更新数据库记录的存储过程,但数据库记录却不更新.CS更新代码如下:
SqlConnection mySqlConnection = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["ConnectionSqlServer"]); 
SqlCommand mySqlCommand = new SqlCommand("Yp_AdminProduct_Update", mySqlConnection);
mySqlCommand.CommandType = CommandType.StoredProcedure;
mySqlCommand.Parameters.AddWithValue("@ProductID", ProductID);
mySqlCommand.Parameters.AddWithValue("@ProBigSortID", iProBigSortID);
mySqlCommand.Parameters.AddWithValue("@ProSmallSortID", iProSmallSortID);
mySqlCommand.Parameters.AddWithValue("@ProvinceID", iProvinceID);
mySqlCommand.Parameters.AddWithValue("@DrugstoreID", iDrugstoreID);
mySqlCommand.Parameters.AddWithValue("@CurrencyName", sCurrencyName);
mySqlCommand.Parameters.AddWithValue("@Preparation", sPreparation);
mySqlCommand.Parameters.AddWithValue("@BusinessMan", sBusinessMan);
mySqlCommand.Parameters.AddWithValue("@ProImage", sProImage);
mySqlCommand.Parameters.AddWithValue("@ProInfo", sProInfo);
mySqlCommand.Parameters.AddWithValue("@Medicare", iMedicare);
mySqlCommand.Parameters.AddWithValue("@UseCardPlace", sUseCardPlace);
mySqlCommand.Parameters.AddWithValue("@WarNumber", sWarNumber);
mySqlCommand.Parameters.AddWithValue("@ViePrice", iViePrice);
try
{
mySqlConnection.Open();
mySqlCommand.ExecuteReader();
mySqlConnection.Close();
Response.Write(@"<script language=JavaScript>{window.alert('商品修改成功,本次操作有效!');javascript:location.href='Admin_ProductAdd.aspx';}</script>");
}
catch (Exception ex)
{
Response.Write("数据库错误,错误原因:" + ex.Message);
Response.End();
}
finally
{
mySqlConnection.Close();
}
存储过程如下:create procedure Yp_AdminProduct_Update 
(@ProductID varchar(1000),
@ProBigSortID varchar(1000),
@ProSmallSortID varchar(1000),
@ProvinceID varchar(1000),
@DrugstoreID varchar(1000),
@CurrencyName varchar(1000),
@Preparation varchar(1000),
@BusinessMan varchar(1000),
@ProImage varchar(1000),
@ProInfo text,
@Medicare varchar(1000),
@UseCardPlace varchar(1000),
@WarNumber varchar(1000),
@ViePrice varchar(1000))
AS
set nocount on
update Yp_Products 
set 
iProBigSortID=@ProBigSortID,
iProSmallSortID=@ProSmallSortID,
iProvinceID=@ProvinceID,
iDrugstoreID=@DrugstoreID,
sCurrencyName=@CurrencyName,
sPreparation=@Preparation,
sBusinessMan=@BusinessMan,
sProImage=@ProImage,
sProInfo=@ProInfo,
iMedicare=@Medicare,
sUseCardPlace=@UseCardPlace,
sWarNumber=@WarNumber,
iViePrice=@ViePrice 
where 
iProducts_ID = @ProductID
set nocount off