[英]Procedure or function has too many arguments specified
Below is my stored procedure for insert: 以下是我用于插入的存储过程:
CREATE PROCEDURE [dbo].[Insertaddress_Master]
(
@add_Zip nvarchar(20),
@add_FullAddress nvarchar(250),
@add_user_Id int,
@add_CreatedDate datetime,
@add_UpdatedDate datetime,
@add_DeletedDate datetime,
@add_IsDeleted bit,
@add_IsPrimary bit,
@add_cntm_Id int,
@add_alt_No nvarchar(20)
)
As
BEGIN
SET NOCOUNT ON
Insert Into [address_Master]
(
[add_Zip],
[add_FullAddress],
[add_user_Id],
[add_CreatedDate],
[add_UpdatedDate],
[add_DeletedDate],
[add_IsDeleted],
[add_IsPrimary],
[add_cntm_Id],
[add_alt_No]
)
Values
(
@add_Zip,
@add_FullAddress,
@add_user_Id,
@add_CreatedDate,
@add_UpdatedDate,
@add_DeletedDate,
@add_IsDeleted,
@add_IsPrimary,
@add_cntm_Id,
@add_alt_No
)
END
Below is code behind function: 下面是功能背后的代码:
protected void AddNew(object sender, EventArgs e)
{
try
{
address_MasterBM obj = new address_MasterBM();
if (((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_Zip")).Text != "")
{
String add_Zipstr = ((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_Zip")).Text;
obj.add_Zip = add_Zipstr;
}
if (((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_FullAddress")).Text != "")
{
String add_FullAddressstr = ((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_FullAddress")).Text;
obj.add_FullAddress = add_FullAddressstr;
}
if (((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_user_Id")).Text != "")
{
Int32 add_user_Idstr = Convert.ToInt32(((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_user_Id")).Text);
obj.add_user_Id = add_user_Idstr;
}
if (((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_CreatedDate")).Text != "")
{
DateTime add_CreatedDatestr = Convert.ToDateTime(((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_CreatedDate")).Text);
obj.add_CreatedDate = add_CreatedDatestr;
}
if (((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_UpdatedDate")).Text != "")
{
DateTime add_UpdatedDatestr = Convert.ToDateTime(((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_UpdatedDate")).Text);
obj.add_UpdatedDate = add_UpdatedDatestr;
}
if (((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_DeletedDate")).Text != "")
{
DateTime add_DeletedDatestr = Convert.ToDateTime(((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_DeletedDate")).Text);
obj.add_DeletedDate = add_DeletedDatestr;
}
if (((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_IsDeleted")).Text != "")
{
Boolean add_IsDeletedstr = Convert.ToBoolean(((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_IsDeleted")).Text);
obj.add_IsDeleted = add_IsDeletedstr;
}
if (((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_IsPrimary")).Text != "")
{
Boolean add_IsPrimarystr = Convert.ToBoolean(((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_IsPrimary")).Text);
obj.add_IsPrimary = add_IsPrimarystr;
}
if (((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_cntm_Id")).Text != "")
{
Int32 add_cntm_Idstr = Convert.ToInt32(((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_cntm_Id")).Text);
obj.add_cntm_Id = add_cntm_Idstr;
}
if (((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_alt_No")).Text != "")
{
String add_alt_Nostr = ((TextBox)gvaddress_Master.FooterRow.FindControl("txtadd_alt_No")).Text;
obj.add_alt_No = add_alt_Nostr;
}
obj.Insertaddress_Master();
BindData();
lblException.Text = "";
}
catch(Exception ex)
{
lblException.Text = ex.Message.ToString();
}
}
Below is business method code: 以下是业务方法代码:
public void Insertaddress_Master() {
try
{
DataAccess obj = new DataAccess();
obj.Provider = EnumProviders.SQLClient;
obj.ConnectionString = ConfigurationManager.ConnectionStrings["connStr"].ToString();
ParamStruct[] param = new ParamStruct[10];
param[0].direction = ParameterDirection.Input;
param[0].ParamName = "@add_Zip";
param[0].DataType = DbType.String;
param[0].value = _add_Zip;
param[1].direction = ParameterDirection.Input;
param[1].ParamName = "@add_FullAddress";
param[1].DataType = DbType.String;
param[1].value = _add_FullAddress;
param[2].direction = ParameterDirection.Input;
param[2].ParamName = "@add_user_Id";
param[2].DataType = DbType.Int32;
param[2].value = _add_user_Id;
param[3].direction = ParameterDirection.Input;
param[3].ParamName = "@add_CreatedDate";
param[3].DataType = DbType.DateTime;
param[3].value = _add_CreatedDate;
param[4].direction = ParameterDirection.Input;
param[4].ParamName = "@add_UpdatedDate";
param[4].DataType = DbType.DateTime;
param[4].value = _add_UpdatedDate;
param[5].direction = ParameterDirection.Input;
param[5].ParamName = "@add_DeletedDate";
param[5].DataType = DbType.DateTime;
param[5].value = _add_DeletedDate;
param[6].direction = ParameterDirection.Input;
param[6].ParamName = "@add_IsDeleted";
param[6].DataType = DbType.Boolean;
param[6].value = _add_IsDeleted;
param[7].direction = ParameterDirection.Input;
param[7].ParamName = "@add_IsPrimary";
param[7].DataType = DbType.Boolean;
param[7].value = _add_IsPrimary;
param[8].direction = ParameterDirection.Input;
param[8].ParamName = "@add_cntm_Id";
param[8].DataType = DbType.Int32;
param[8].value = _add_cntm_Id;
param[9].direction = ParameterDirection.Input;
param[9].ParamName = "@add_alt_No";
param[9].DataType = DbType.String;
param[9].value = _add_alt_No;
obj.ExecScalar("Insertaddress_Master", CommandType.StoredProcedure, param);
_returnBoolean = true;
}
catch (DataException ex)
{
_returnBoolean = false;
throw ex;
}
}
when I try to insert data using this code it generates exception saying " Procedure or function Insertaddress_Master has too many arguments specified". 当我尝试使用此代码插入数据时,它会生成异常,指出“过程或函数Insertaddress_Master指定了太多参数”。 Can anyone help solving this problem. 任何人都可以帮助解决这个问题。
I've read all previous thread on this topic but couldn't find appropriate solution yet. 我已经阅读了有关该主题的所有先前主题,但尚未找到合适的解决方案。
SqlCommand objCommand = new SqlCommand();
您可以重新创建该对象,然后它将起作用。
I got this answer. 我得到了这个答案。
You have two fields: 您有两个字段:
Is Deleted
Is Primarry
You have to passed the boolean that may have true/false. 您必须传递可能具有true / false的布尔值。
Try passing 1 for true and 0 for false. 尝试将1传递为true,将0传递为false。
This should do the trick 这应该可以解决问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.