当我使用save_click时遇到上述错误,这是我的代码
protected void btn_save_Click(object sender, EventArgs e)
{
try
{
if (Convert.ToInt32(obj_grp.checkExist(txt_grpname.Text)) != 0)
{
aler("grp", "grp name already exists");
SetFocus(txt_grpname);
}
else
{
obj_grp.grp_NAME = txt_grpname.Text.Trim();
obj_grp.effective_DATE = Convert.ToDateTime( txt_edate.Text);
obj_grp.M_DATE = Convert.ToDateTime(txt_mdate.Text);
int val = obj_grp.add();
if (val > 0)
{
aler("grp", "grpname Registered sucessfully");
}
else
{
aler("grp", "group Not Registered ");
}
}
}
catch (Exception)
{
throw;
}
}
我的存储过程是
create procedure [dbo].[insert_grp](@grpid int,@grpname varchar(50),@edate datetime,@mdate datetime)
as insert into grp values(@grpname,@edate,@mdate)
这里grpid是身份......
答案 0 :(得分:0)
如果@grpid是身份,那么为什么要在存储过程中恢复它。
create procedure [dbo].[insert_grp](@grpid int,@grpname varchar(50),@edate datetime,@mdate datetime)
as insert into grp values(@grpname,@edate,@mdate)
你将三个值传递给过程,这就是为什么它不能将值赋给第四个参数,即mdate。所以让你的存储过程像
create procedure [dbo].[insert_grp](@grpname varchar(50),@edate datetime,@mdate datetime)
as insert into grp values(@grpname,@edate,@mdate)