字符串整数转换?编译器错误消息:CS1502

时间:2016-05-08 17:25:33

标签: ms-access error-handling

localhost.WebService x = new localhost.WebService();סרוויס 

if (Session["UserName"]!= null)
{
    string UserName = Session["UserName "].ToString();
    HiddenField HiddenField1 = (HiddenField)e.Item.FindControl("HiddenField1");
    Image y = (Image)e.Item.FindControl("Image1");

    int Price = int.Parse(HiddenField1.Value);
    int BuyerID = int.Parse(HiddenField1.Value);
    x.AddOrder(BuyerID, Price, y.ImageUrl); 
}
else 
    Response.Redirect("Registration.aspx");

[WebMethod]
public void AddOrder(int BuyerID, int Price, int ArtPiece)
{
    OleDbDataAdapter x = new OleDbDataAdapter("AddOrder", objConn);
    x.SelectCommand.CommandType = CommandType.StoredProcedure;

    OleDbParameter objParam = new OleDbParameter("@BuyerID", OleDbType.Char);
    objParam.Value = BuyerID;
    x.SelectCommand.Parameters.Add(objParam);

    objParam = new OleDbParameter("@Price", OleDbType.Char);
    objParam.Value = Price;
    x.SelectCommand.Parameters.Add(objParam);

    objParam = new OleDbParameter("@ArtPiece", OleDbType.Char);
    objParam.Value = ArtPiece;
    x.SelectCommand.Parameters.Add(objParam);

    x.SelectCommand.ExecuteNonQuery();
}

ArtPiece是Access文件中的字符串类型。在这一行

x.AddOrder(BuyerID, Price, y.ImageUrl); 

y.ImageUrl显示错误。我该怎么做才能解决它?

1 个答案:

答案 0 :(得分:0)

您已将ArtPiece声明为 int

localhost:2222

我想它应该是:

public void AddOrder(int BuyerID, int Price, int ArtPiece)