过程或函数'addrmpbirth'需要参数'@bday',这是未提供的。 [英] Procedure or function 'addrmpbirth' expects parameter '@bday', which was not supplied.

查看:78
本文介绍了过程或函数'addrmpbirth'需要参数'@bday',这是未提供的。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道这个代码有什么问题



存储过程是: -



I don''t Know what is the problem here with this code

the stored proc is :-

alter proc [dbo].[addrmpbirth]
@bday varchar(50),
@bm varchar(50),
@by varchar(50)
as
begin
insert into Employee (EBirthday,EBirthMonth,EBirthyear) values (@bday,@bm,@by)
end





&安培; C#代码是: -





& C# code is :-

public DataTable Executereadercommand()
        {
            con.Open();
            com.Connection = con;
            SqlDataReader sdr = com.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(sdr);
            con.Close();
            return dt;
        }

        public DataTable addbirthemp(string bd,string bm,string by) 
        {
            com.CommandText = "addrmpbirth";
            com.CommandType = CommandType.StoredProcedure;
            com.Parameters.Clear();
            com.Parameters.AddWithValue("@bday",bd);
            com.Parameters.AddWithValue("@bm",bm);
            com.Parameters.AddWithValue("@by",by);
          DataTable dt=  Executereadercommand();
          return dt;
        }

推荐答案

为什么要尝试使用带有DataTable Load的INSERT语句?这似乎是一个非常大的问题。
Why are you trying to use an INSERT statement with a DataTable Load? That would seem to be a pretty big problem right there.


1)在您的情况下,它是您要执行的NonQuery语句,它不返回结果集。

2)我看到你正在尝试重用一些对象(例如 com )。不要。



首先在之前添加 com.ExecuteNonQuery(); 语句DataTable dt = Executereadercommand();
1) In your case, it is a NonQuery statement you want to execute, that does not return a result set.
2) As I see you are trying to reuse some objects (com for example). Don''t.

For the start add a com.ExecuteNonQuery(); statement before DataTable dt=Executereadercommand();


这篇关于过程或函数'addrmpbirth'需要参数'@bday',这是未提供的。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆