【问题标题】:Procedure has no parameters and arguments were supplied过程没有参数并且提供了参数
【发布时间】:2016-06-20 09:53:55
【问题描述】:

我想显示存储过程,但我收到错误:Procedure SPselcocpd has no parameters and arguments are provided。

cs页面

 lbllgintype.Text = com;
 lblname.Text = com1;
 sqlq = "";
 sqlq = "select [name] from admin where userid='" + com1 + "'";
 SqlDataAdapter da1 = new SqlDataAdapter(sqlq, con);
 DataSet ds = new DataSet();
 da1.Fill(ds);
 name.Text = "";
 name.Text = ds.Tables[0].Rows[0][0].ToString();
 SqlCommand cmd = new SqlCommand("SPselcocpd");
 cmd.Parameters.Clear();
 cmd.CommandType = CommandType.StoredProcedure;
 cmd.Connection = con;
 cmd.Parameters.AddWithValue("@comname", comname.Text);
 SqlDataAdapter da2 = new SqlDataAdapter(cmd);
 DataSet dt1 = new DataSet();
 da2.Fill(dt1);
 con.Open();
 brand.Items.Add("<--select-->");
 for (int i = 0; i < dt1.Tables[0].Rows.Count; i++)
 {
     brand.Items.Add(dt1.Tables[0].Rows[i][0].ToString());
 }
 con.Close();`

SQL 存储过程

alter procedure SPselbdralt
@comname varchar(100)
as
begin
select brandname from rpmallot where comname=(select id from companydetails where comname=@comname)
end

请尽快解决我的问题我正在做一个实时项目

【问题讨论】:

    标签: c# sql-server stored-procedures


    【解决方案1】:

    请确保,您使用的是正确的 sp

    我想显示存储过程,但出现以下错误 过程 SPselcocpd 没有参数并且参数是 提供。

    在代码中你调用不同的 SP SPselcocpd

    SqlCommand cmd = new SqlCommand("SPselcocpd");  // Here it is SPselcocpd
    

    SQL SP 是 改变程序 SPselbdralt

    确认您调用的是正确的 SP

    【讨论】:

      【解决方案2】:

      您调用了错误的存储过程。

      改变

      SqlCommand cmd = new SqlCommand("SPselcocpd");
      

      收件人

      SqlCommand cmd = new SqlCommand("SPselbdralt");
      

      【讨论】:

        猜你喜欢
        • 2018-03-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-12-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多