【问题标题】:The best overloaded method match for 'DataClass.addrechargeplans(string, string, string, int, string, string, string)' has some invalid arguments'DataClass.addrechargeplans(string, string, string, int, string, string, string)' 的最佳重载方法匹配有一些无效参数
【发布时间】:2014-04-10 18:53:08
【问题描述】:

重载方法匹配 .... 有一些无效参数 In 我们有表名“RechargePlans”和列名的数据库是 圈子、运营商、充值类型、金额、通话时间、有效期、说明

  protected void Button1_Click(object sender, EventArgs e)
  {
      int i = 0;
      i = obj.addrechargeplans(circleddl.SelectedItem.Text, operatorddl.SelectedItem.Value,rechargetype.SelectedItem.Text, amt, taktme.Text, valdty.Text, descpn.Text);
        if (i > 0)
        {
            Response.Write("<script>alert(' inserted')</script>");
        }
        else
        {
            Response.Write("<script>alert('error')</script>");
        }
     }

数据类

public int addrechargeplans(string Circle, string Operator, string RechargeType, int     Amount, string Talktime, string Validity, string Description)
    {
        con.Open();
        SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "sp_rechargeplans";
        cmd.Parameters.AddWithValue("@circle", Circle);
        cmd.Parameters.AddWithValue("@operator", Operator);
        cmd.Parameters.AddWithValue("@rechargetype", RechargeType);
        cmd.Parameters.AddWithValue("@amount", Amount);
        cmd.Parameters.AddWithValue("@talktime", Talktime);
        cmd.Parameters.AddWithValue("@validity", Validity);
        cmd.Parameters.AddWithValue("@description", Description);
        int i;
        i = cmd.ExecuteNonQuery();
        con.Close();
        return i;
    }

【问题讨论】:

  • amt 的类型是什么?
  • 错误信息应该告诉你它尝试使用的类型以及声明使用的方法,请查看完整的编译器错误以找出问题所在。
  • 这应该是一个直截了当的错误,可以很容易地解决,你能检查一下 amt 是什么吗?

标签: c# asp.net .net visual-studio-2010


【解决方案1】:

根据错误消息,您至少有一个无效参数。我们不知道amt变量的类型是什么。根据你的方法定义应该是integer

【讨论】:

  • 我猜是amt 不是整数。
  • operatorddl.SelectedItem.Value 是一个字符串,但为您的第二部分答案 +1。
  • @Habib 是的,你是对的,我检查了 Value 属性,它是字符串
  • @Tajkumar 显然不是。请再检查一遍
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-30
  • 2022-01-08
  • 2015-12-11
  • 1970-01-01
  • 2017-06-13
  • 1970-01-01
相关资源
最近更新 更多