这是我用来更新表的更新查询。它抛出一个异常“在哪里附近的语法不正确”为什么这个例外?我不知道。
public bool UpdateLocationCountintoMerchantPackage(int PackageID, long MerchantID,int LocationCount)
{
try
{
SqlParameter[] parameters = new SqlParameter[]
{
new SqlParameter("@packageID",PackageID),
new SqlParameter("@merchantID",MerchantID ),
new SqlParameter("@locationCount",LocationCount )
};
string CommandText = string.Empty;
CommandText = "Update Merchant_Package SET LocationCount Where MerchantID=@MerchantID";
string ConnectionString = DbConnectionStrings.GetDbConnectionString();
SqlHelper.ExecuteNonQuery(ConnectionString, System.Data.CommandType.Text, CommandText, parameters);
return true;
}
catch (SqlException ex)
{
LogError("Error Occurred When Saving Merchant Location Count Data : MerchantID:" + MerchantID.ToString(), ex);
return false;
}
}
从
调用此函数protected void imgbtnSubmit_Click(object sender, ImageClickEventArgs e)
{
UpdatePaymentInfo();
string QueryString = Request.QueryString.ToString();
if (string.Equals(QueryString, "MerchantProfilePages"))
{
Response.Redirect(ApplicationData.URL_ADD_PROFILE_PAGE, false);
Merchant mrchnt = new Merchant();
int PackId = mrchnt.PackageID;
int x = GetLocationCount() + 1;
mrchnt.UpdateLocationCountintoMerchantPackage(PackId, merchantId, x);
}
答案 0 :(得分:13)
这是你的“SET LocationCount”的一个问题 - 你没有把它设置为等于任何东西。这就是为什么它抱怨WHERE。
答案 1 :(得分:3)
使用SQL,如:
Update Merchant_Package SET LocationCount=@LocationCount
Where MerchantID=@MerchantID
遇到WHERE时报告了第1行的错误