C# 更新查询位置附近的语法不正确
下面是我用来更新表的更新查询。它向我抛出了一个异常错误的语法,为什么该异常用于何处?我不知道C# 更新查询位置附近的语法不正确,c#,asp.net,sql,C#,Asp.net,Sql,下面是我用来更新表的更新查询。它向我抛出了一个异常错误的语法,为什么该异常用于何处?我不知道 public bool UpdateLocationCountintoMerchantPackage(int PackageID, long MerchantID,int LocationCount) { try { SqlParameter[] parameters = new SqlParameter[]
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);
}
这是您设置的LocationCount的问题-您没有将其设置为任何值。这就是为什么它抱怨WHERE。这是您设置的LocationCount的问题-您没有将其设置为任何值。这就是它抱怨WHERE的原因。使用SQL,比如:
Update Merchant_Package SET LocationCount=@LocationCount
Where MerchantID=@MerchantID
在遇到WHERE时报告了第1行上的错误使用SQL like:
Update Merchant_Package SET LocationCount=@LocationCount
Where MerchantID=@MerchantID
在遇到WHERE时报告了第1行上的错误,但我已从“x”传递了LocationCount值。这是错误的吗?您确实传入了参数,但没有使用它。更新Merchant_Package SET LocationCount=@LocationCount其中MerchantID=@MerchantID Public bool UpdateLocationCountntMerchantPackageInt PackageID,long MerchantID,int LocationCount当我调试时,它会显示x的值。所以我想我通过了。让我试试,然后回来。谢谢但我已经从“x”传递了LocationCount值。这是错误的吗?您确实传入了参数,但没有使用它。更新Merchant_Package SET LocationCount=@LocationCount其中MerchantID=@MerchantID Public bool UpdateLocationCountntMerchantPackageInt PackageID,long MerchantID,int LocationCount当我调试时,它会显示x的值。所以我想我通过了。让我试试,然后回来。谢谢