hi
I'm a newbie to ASP.net development.
I'm getting this error message "Procedure or function has too many arguments specified." when inserting data via the stored procedure into DB.
Can anyone help me with this error?
thanks

my code:

 void InsertIntoVahed()
    {
        SqlConnection sn = new SqlConnection("Data Source=Server;Initial Catalog=ab;User ID=sa;Password=12345");
        SqlCommand sc = new SqlCommand("Insert_VAHED", sn);
        sc.CommandType = System.Data.CommandType.StoredProcedure;
        sc.CommandText = "Insert_VAHED";
        sc.Parameters.Add("@VAHED_NO", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@ID_FEMAIN", SqlDbType.Int).Value = 1;
        sc.Parameters.Add("@ID_ADDR", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@GHARM", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@GHAR", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@ADD_ID", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@DATE_IJ", SqlDbType.NVarChar).Value = DateTime.Now.ToString();
        sc.Parameters.Add("@DATE_IJ_F", SqlDbType.NVarChar).Value = EX.PersianCalender();
        sc.Parameters.Add("@KOL_ARSE", SqlDbType.Int).Value = v.KOL_ARSE;
        sc.Parameters.Add("@KOL_AYAN", SqlDbType.Int).Value = v.KOL_AYAN;
        sc.Parameters.Add("@MOFID", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@MOSHA", SqlDbType.Int).Value = v.MOSHA;
        sc.Parameters.Add("@T_VAHED", SqlDbType.Int).Value = v.T_VAHED;
        sc.Parameters.Add("@T_BLOCK", SqlDbType.Int).Value = v.T_BLOCK;
        sc.Parameters.Add("@T_TABAGH", SqlDbType.Int).Value = v.T_TABAGH;
        sc.Parameters.Add("@AB_ENSH", SqlDbType.NVarChar).Value = v.AB_ENSH;
        sc.Parameters.Add("@FA_ENSH", SqlDbType.NVarChar).Value = v.FA_ENSH;
        sc.Parameters.Add("@AB_TAFK", SqlDbType.NVarChar).Value = v.AB_TAFK;
        sc.Parameters.Add("@FA_TAFk", SqlDbType.NVarChar).Value = v.FA_TAFk;
        sc.Parameters.Add("@Z1", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@Z2", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@Z3", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@Z4", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@Z5", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@Z6", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@Z7", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@Z8", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@Z9", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@Z10", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@ELAT", SqlDbType.NVarChar).Value = v.ELAT;
        sc.Parameters.Add("@ELAT_CD", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@MN_SHAHR", SqlDbType.NVarChar).Value = v.MN_SHAHR;
        sc.Parameters.Add("@TOT_DAR", SqlDbType.Int).Value = v.TOT_DAR;
        sc.Parameters.Add("@TAKHFIF_NAM", SqlDbType.NVarChar).Value = "0";
        sc.Parameters.Add("@TAKHFIF_CD", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@GHAR_ZARF", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@TAKHFIF_AMT", SqlDbType.Int).Value = v.TAKHFIF_AMT;
        sc.Parameters.Add("@BRANCH_CD", SqlDbType.Int).Value = v.BRANCH_CD;
        sc.Parameters.Add("@BRNAM", SqlDbType.NVarChar).Value = "0";
        sc.Parameters.Add("@FACD", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@FANAM", SqlDbType.NVarChar).Value = "0";
        sc.Parameters.Add("@ABNASB", SqlDbType.NVarChar).Value = v.ABNASB;
        sc.Parameters.Add("@FANASB", SqlDbType.Int).Value = v.FANASB;
        sc.Parameters.Add("@ABTOSE", SqlDbType.Int).Value = v.ABTOSE;
        sc.Parameters.Add("@FATOSE", SqlDbType.Int).Value = v.FATOSE;
        sc.Parameters.Add("@TOTAL_AB", SqlDbType.Int).Value = v.TOTAL_AB;
        sc.Parameters.Add("@TOTAL_FA", SqlDbType.Int).Value = v.TOTAL_FA;
        sc.Parameters.Add("@NAGHDY_AB", SqlDbType.Int).Value = v.NAGHDY_AB;
        sc.Parameters.Add("@NAGHDY_FA", SqlDbType.Int).Value = v.NAGHDY_FA;
        sc.Parameters.Add("@NAGHDY_TOT", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@AGHAMT", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@AGHAB", SqlDbType.Int).Value = v.AGHAB;
        sc.Parameters.Add("@AGHFA", SqlDbType.Int).Value = v.AGHFA;
        sc.Parameters.Add("@AGHTOT", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@AGHNO", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@SABT_DATE", SqlDbType.NVarChar).Value = "0";
        sc.Parameters.Add("@SABT_DATE_F", SqlDbType.NVarChar).Value = "0";
        sc.Parameters.Add("@VOSDATE", SqlDbType.NVarChar).Value = "0";
        sc.Parameters.Add("@VOSDATEF", SqlDbType.NVarChar).Value = "0";
        sc.Parameters.Add("@PAR_NO", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@VAHEDASL", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@VAHEDFAR", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@USERCODE", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@USERNAM", SqlDbType.NVarChar).Value = "0";
        sc.Parameters.Add("@KARBARICD", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@KARBARINUM", SqlDbType.NVarChar).Value = "0";
        sc.Parameters.Add("@ENSH_TYPE_CD", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@ENSH_TYPE_NAM", SqlDbType.NVarChar).Value = "0";
        sc.Parameters.Add("@ABSSPER", SqlDbType.Int).Value = 0;
        sc.Parameters.Add("@ABSSAMT", SqlDbType.Int).Value = 0;
        sc.Connection.Open();
        sc.ExecuteNonQuery();
        sc.Connection.Close();
    }

storde procedure :

ALTER PROCEDURE [dbo].[Insert_VAHED]
@VAHED_NO int,
@ID_FEMAIN numeric(8,0),
@ID_ADDR numeric(8,0),
@GHARM numeric(7,0),
@GHAR numeric(7,0),
@ADD_ID int,
@DATE_IJ nvarchar(50),
@DATE_IJ_F nvarchar(50),
@KOL_ARSE numeric(9,0),
@KOL_AYAN numeric(8,0),
@MOFID numeric(8,0),
@MOSHA numeric(8,0),
@T_VAHED numeric(4,0),
@T_BLOCK numeric(4,0),
@T_TABAGH numeric(2,0),
@AB_ENSH nvarchar(50),
@FA_ENSH nvarchar(50),
@AB_TAFK nvarchar(50),
@FA_TAFk nvarchar(50),
@Z1 numeric(12,0),
@Z2 numeric(12,0),
@Z3 numeric(12,0),
@Z4 numeric(12,0),
@Z5 numeric(12,0),
@Z6 numeric(12,0),
@Z7 numeric(12,0),
@Z8 numeric(12,0),
@Z9 numeric(12,0),
@Z10 numeric(12,0),
@ELAT nvarchar(20),
@ELAT_CD numeric(3,0),
@MN_SHAHR nvarchar(50),
@TOT_DAR numeric(12,0),
@TAKHFIF_NAM nvarchar(50),
@TAKHFIF_CD numeric(18,0),
@GHAR_ZARF numeric(18,0),
@TAKHFIF_AMT numeric(18,0),
@BRANCH_CD numeric(3,0),
@BRNAM nvarchar(50),
@FACD numeric(18,0),
@FANAM nvarchar(50),
@ABNASB nvarchar(50),
@FANASB numeric(18,0),
@ABTOSE numeric(18,0),
@FATOSE numeric(18,0),
@TOTAL_AB numeric(18,0),
@TOTAL_FA numeric(18,0),
@NAGHDY_AB numeric(18,0),
@NAGHDY_FA numeric(18,0),
--@NAGHDY_TOT numeric(18,0),
@AGHAMT numeric(18,0),
@AGHAB numeric(18,0),
@AGHFA numeric(18,0),
@AGHTOT numeric(18,0),
@AGHNO numeric(18,0),
@SABT_DATE nvarchar(50),
@SABT_DATE_F nvarchar(50),
@VOSDATE nvarchar(50),
@VOSDATEF nvarchar(50),
@PAR_NO numeric(18,0),
@VAHEDASL numeric(4,0),
@VAHEDFAR numeric(4,0),
@USERCODE numeric(18,0),
@USERNAM nvarchar(50),
@KARBARICD numeric(18,0),
@KARBARINUM nvarchar(50),
@ENSH_TYPE_CD numeric(18,0),
@ENSH_TYPE_NAM nvarchar(50),
@ABSSPER int,
@ABSSAMT numeric(18,0)
AS
BEGIN

declare @NAGHDY_TOT numeric(18,0);
set @NAGHDY_TOT = @TOTAL_AB + @TOTAL_FA;

Hi Faranak.

Well as i have seen your code there is not problem inside.

But i dont it is better to look @ the argument that you are inserting.

It may be distinguish in order.

So please check the order.

thanks for your reply but i check it again and i can't find problem.:((

Hi Farank.

A code should look like in this Manner.

I think you should check out from below code.

Please reply me on Message.

public void Insert(string strName,string strCName,int nWeekHour,string strPassword,string strEMail,out int nAlreadyIn)
        {
            nAlreadyIn=0;
            // Establish Connection
            SqlConnection oConnection = GetConnection();

            // build the command
            SqlCommand oCommand = new SqlCommand("InsertPerson",oConnection);
            oCommand.CommandType=CommandType.StoredProcedure;

            // Parameters
            SqlParameter paraName= new SqlParameter("@Name",SqlDbType.Char,50);
            paraName.Value=strName;
            oCommand.Parameters.Add(paraName);

            SqlParameter paraCName= new SqlParameter("@CName",SqlDbType.Char,50);
            paraCName.Value=strCName;
            oCommand.Parameters.Add(paraCName);

            SqlParameter paraWeekHour = new SqlParameter("@WeekHour",SqlDbType.Int,2);
            paraWeekHour.Value=nWeekHour;
            oCommand.Parameters.Add(paraWeekHour);

            SqlParameter paraPassword= new SqlParameter("@Password",SqlDbType.Char,50);
            paraPassword.Value=strPassword;
            oCommand.Parameters.Add(paraPassword);

            SqlParameter paraEMail= new SqlParameter("@EMail",SqlDbType.Char,50);
            paraEMail.Value=strEMail;
            oCommand.Parameters.Add(paraEMail);

            SqlParameter paraAlreadyIn = new SqlParameter("@AlreadyIn",SqlDbType.Int,2);
            paraAlreadyIn.Direction = ParameterDirection.Output;
            oCommand.Parameters.Add(paraAlreadyIn);

            try
            {
                oConnection.Open();
                oCommand.ExecuteNonQuery();
                nAlreadyIn=(int) paraAlreadyIn.Value;

            }
            catch(Exception oException)
            {
                throw oException;
            }
            finally
            {
                oConnection.Close();
            }
        }

aswhat the problem/error explains, you might be passing too many values into the function. check to see that you are calling... wait a second.. read your public void line:

public void Insert(string strName,string strCName,int nWeekHour,string strPassword,string strEMail,out int nAlreadyIn)

The problem with this is a couple things. what is "out int nAlreadyIn"? You're calling two separate variables with one undeclared. This is most likely causing your problem. Also, remove the nAlreadyIn as you are setting the value of it inside the function anyway. Plus, you aren't even using anything that is like called out. Just declare it inside. Try replacing that line with the one below:

public void Insert(string strName, string strCName, int nWeekHour, string strPassword, string strEMail)
{
int nAlreadyIn=0;
...
...

Your problem lies with the call of the function. Just make sure that when you call Insert now, that it looks something like below calling only 2 strings, then an integer, then 2 more strings:

<%# Insert("name", "cname", 8, "password", "email@email.com") %>

thanks for your reply , but your solution souldn't help me to solve my problem. :((

public void InsertIntoVahed()
{
int nalready = 0;
SqlConnection sn = new SqlConnection("...");
SqlCommand sc = new SqlCommand("Insert_VAHED", sn);
sc.CommandType = System.Data.CommandType.StoredProcedure;
//parameters
SqlParameter vahedNo=new SqlParameter("@VAHED_NO",SqlDbType.Int);
vahedNo.Value=0;
sc.Parameters.Add(vahedNo);


SqlParameter IDfemain=new SqlParameter("@ID_FEMAIN",SqlDbType.Int,8);
IDfemain.Value=1;
sc.Parameters.Add(IDfemain);


SqlParameter IDaddr=new SqlParameter("@ID_ADDR",SqlDbType.Int,8);
IDaddr.Value=0;
sc.Parameters.Add(IDaddr);


SqlParameter gharm = new SqlParameter("GHARM", SqlDbType.Int, 7);
gharm.Value = 0;
sc.Parameters.Add(gharm);


SqlParameter ghar = new SqlParameter("@GHAR", SqlDbType.Int, 7);
ghar.Value = 0;
sc.Parameters.Add(ghar);


SqlParameter addID = new SqlParameter("@ADD_ID", SqlDbType.Int);
addID.Value = 0;
sc.Parameters.Add(addID);


SqlParameter dateIJ = new SqlParameter("@DATE_IJ", SqlDbType.NVarChar, 50);
dateIJ.Value = DateTime.Now.ToString();
sc.Parameters.Add(dateIJ);


SqlParameter dateIJF = new SqlParameter("@DATE_IJ_F", SqlDbType.NVarChar, 50);
dateIJF.Value = EX.PersianCalender();
sc.Parameters.Add(dateIJF);


SqlParameter kolArse = new SqlParameter("@KOL_ARSE", SqlDbType.Int,9);
kolArse.Value = v.KOL_ARSE;
sc.Parameters.Add(kolArse);


SqlParameter kolAyan = new SqlParameter("@KOL_AYAN", SqlDbType.Int, 8);
kolAyan.Value = v.KOL_AYAN;
sc.Parameters.Add(kolAyan);


SqlParameter mofid = new SqlParameter("@MOFID", SqlDbType.Int, 8);
mofid.Value = 0;
sc.Parameters.Add(mofid);


SqlParameter Tvahed=new SqlParameter("@T_VAHED", SqlDbType.Int,4);
Tvahed.Value=v.T_VAHED;
sc.Parameters.Add(Tvahed);


SqlParameter Ttabaghe=new SqlParameter("@T_TABAGH", SqlDbType.Int,2);
Ttabaghe.Value=v.T_TABAGH;
sc.Parameters.Add(Ttabaghe);


SqlParameter abEnsheab=new SqlParameter("@AB_ENSH", SqlDbType.NVarChar,50);
abEnsheab.Value=v.AB_ENSH;
sc.Parameters.Add(abEnsheab);


SqlParameter tBlock=new SqlParameter("@T_BLOCK", SqlDbType.Int,4);
tBlock.Value=v.T_BLOCK;
sc.Parameters.Add(tBlock);


SqlParameter faEnsheab=new SqlParameter("@FA_ENSH", SqlDbType.NVarChar,50);
faEnsheab.Value=v.FA_ENSH;
sc.Parameters.Add(faEnsheab);


SqlParameter abTafkik=new SqlParameter("@AB_TAFK", SqlDbType.NVarChar,50);
abTafkik.Value=v.AB_TAFK;
sc.Parameters.Add(abTafkik);


SqlParameter mosha = new SqlParameter("@MOSHA", SqlDbType.Int, 8);
mosha.Value = v.MOSHA;
sc.Parameters.Add(mosha);


SqlParameter faTafkik = new SqlParameter("@FA_TAFk", SqlDbType.NVarChar, 50);
faTafkik.Value = v.FA_TAFk;
sc.Parameters.Add(faTafkik);


SqlParameter z1 = new SqlParameter("@Z1", SqlDbType.Int, 12);
z1.Value = 0;
sc.Parameters.Add(z1);


SqlParameter z2 = new SqlParameter("@Z2", SqlDbType.Int, 12);
z2.Value = 0;
sc.Parameters.Add(z2);


SqlParameter z3 = new SqlParameter("@Z3", SqlDbType.Int, 12);
z3.Value = 0;
sc.Parameters.Add(z3);


SqlParameter z4 = new SqlParameter("@Z4", SqlDbType.Int, 12);
z4.Value = 0;
sc.Parameters.Add(z4);


SqlParameter z5 = new SqlParameter("@Z5", SqlDbType.Int, 12);
z5.Value = 0;
sc.Parameters.Add(z5);


SqlParameter z6 = new SqlParameter("@Z6", SqlDbType.Int, 12);
z6.Value = 0;
sc.Parameters.Add(z6);


SqlParameter z7 = new SqlParameter("@Z7", SqlDbType.Int, 12);
z7.Value = 0;
sc.Parameters.Add(z7);


SqlParameter z8 = new SqlParameter("@Z8", SqlDbType.Int, 12);
z8.Value = 0;
sc.Parameters.Add(z8);


SqlParameter z9 = new SqlParameter("@Z9", SqlDbType.Int, 12);
z9.Value = 0;
sc.Parameters.Add(z9);


SqlParameter z10 = new SqlParameter("@Z10", SqlDbType.Int, 12);
z10.Value = 0;
sc.Parameters.Add(z10);


SqlParameter elat = new SqlParameter("@ELAT", SqlDbType.NVarChar, 20);
elat.Value = v.ELAT;
sc.Parameters.Add(elat);


SqlParameter elatcd = new SqlParameter("@ELAT_CD", SqlDbType.Int, 3);
elatcd.Value = 0;
sc.Parameters.Add(elatcd);


SqlParameter mnShahr = new SqlParameter("@MN_SHAHR", SqlDbType.NVarChar, 50);
mnShahr.Value = v.MN_SHAHR;
sc.Parameters.Add(mnShahr);


SqlParameter totDAR = new SqlParameter("@TOT_DAR", SqlDbType.Int, 12);
totDAR.Value = v.TOT_DAR;
sc.Parameters.Add(totDAR);


SqlParameter takhfifNam=new SqlParameter("@TAKHFIF_NAM", SqlDbType.NVarChar,50);
takhfifNam.Value="0";
sc.Parameters.Add(takhfifNam);


SqlParameter takhfifcd = new SqlParameter("@TAKHFIF_CD", SqlDbType.Int,18);
takhfifcd.Value = 0;
sc.Parameters.Add(takhfifcd);


SqlParameter gharZarf = new SqlParameter("@GHAR_ZARF", SqlDbType.Int, 18);
gharZarf.Value = 0;
sc.Parameters.Add(gharZarf);


SqlParameter takhfifAMT = new SqlParameter("@TAKHFIF_AMT", SqlDbType.Int, 18);
takhfifAMT.Value = v.TAKHFIF_AMT;
sc.Parameters.Add(takhfifAMT);


SqlParameter BRANCH_CD = new SqlParameter("@BRANCH_CD", SqlDbType.Int, 3);
BRANCH_CD.Value = v.BRANCH_CD;
sc.Parameters.Add(BRANCH_CD);


SqlParameter BRNAM = new SqlParameter("@BRNAM", SqlDbType.NVarChar, 50);
BRNAM.Value = "0";
sc.Parameters.Add(BRNAM);


SqlParameter FACD = new SqlParameter("@FACD", SqlDbType.Int, 18);
FACD.Value = v.FACD;
sc.Parameters.Add(FACD);


SqlParameter FANAM = new SqlParameter("@FANAM", SqlDbType.NVarChar, 50);
FANAM.Value = "0";
sc.Parameters.Add(FANAM);


SqlParameter ABNASB = new SqlParameter("@ABNASB", SqlDbType.NVarChar, 50);
ABNASB.Value = v.ABNASB;
sc.Parameters.Add(ABNASB);


SqlParameter FANASB = new SqlParameter("@FANASB", SqlDbType.Int, 18);
FANASB.Value = v.FANASB;
sc.Parameters.Add(FANASB);


SqlParameter ABTOSE = new SqlParameter("@ABTOSE", SqlDbType.Int, 18);
ABTOSE.Value = v.ABTOSE;
sc.Parameters.Add(ABTOSE);


SqlParameter FATOSE = new SqlParameter("@FATOSE", SqlDbType.Int, 18);
FATOSE.Value = v.FATOSE;
sc.Parameters.Add(FATOSE);


SqlParameter TOTAL_AB = new SqlParameter("@TOTAL_AB", SqlDbType.Int, 18);
TOTAL_AB.Value = v.TOTAL_AB;
sc.Parameters.Add(TOTAL_AB);


SqlParameter TOTAL_FA = new SqlParameter("@TOTAL_FA", SqlDbType.Int, 18);
TOTAL_FA.Value = v.TOTAL_FA;
sc.Parameters.Add(TOTAL_FA);


SqlParameter NAGHDY_AB = new SqlParameter("@NAGHDY_AB", SqlDbType.Int, 18);
NAGHDY_AB.Value = v.NAGHDY_AB;
sc.Parameters.Add(NAGHDY_AB);


SqlParameter NAGHDY_FA = new SqlParameter("@NAGHDY_FA", SqlDbType.Int, 18);
NAGHDY_FA.Value = v.NAGHDY_FA;
sc.Parameters.Add(NAGHDY_FA);


SqlParameter NAGHDY_TOT = new SqlParameter("@NAGHDY_TOT", SqlDbType.Int, 18);
NAGHDY_TOT.Value = 0;
sc.Parameters.Add(NAGHDY_TOT);


SqlParameter AGHAMT = new SqlParameter("@AGHAMT", SqlDbType.Int, 18);
AGHAMT.Value = 0;
sc.Parameters.Add(AGHAMT);


SqlParameter AGHAB = new SqlParameter("@AGHAB", SqlDbType.Int, 18);
AGHAB.Value = 0;
sc.Parameters.Add(AGHAB);


SqlParameter AGHFA = new SqlParameter("@AGHFA", SqlDbType.Int, 18);
AGHFA.Value = v.AGHFA;
sc.Parameters.Add(AGHFA);


SqlParameter AGHTOT = new SqlParameter("@AGHTOT", SqlDbType.Int, 18);
AGHTOT.Value = 0;
sc.Parameters.Add(AGHTOT);


SqlParameter AGHNO = new SqlParameter("@AGHNO", SqlDbType.Int, 18);
AGHNO.Value = 0;
sc.Parameters.Add(AGHNO);


SqlParameter SABT_DATE = new SqlParameter("@SABT_DATE", SqlDbType.NVarChar, 50);
SABT_DATE.Value = "0";
sc.Parameters.Add(SABT_DATE);


SqlParameter SABT_DATE_F = new SqlParameter("@SABT_DATE_F", SqlDbType.NVarChar, 50);
SABT_DATE_F.Value = "0";
sc.Parameters.Add(SABT_DATE_F);


SqlParameter VAHEDASL = new SqlParameter("@VAHEDASL", SqlDbType.Int, 4);
VAHEDASL.Value = 0;
sc.Parameters.Add(VAHEDASL);


SqlParameter VOSDATE = new SqlParameter("@VOSDATE", SqlDbType.NVarChar, 50);
VOSDATE.Value = "0";
sc.Parameters.Add(VOSDATE);


SqlParameter VOSDATEF = new SqlParameter("@VOSDATEF", SqlDbType.NVarChar, 50);
VOSDATEF.Value = "0";
sc.Parameters.Add(VOSDATEF);


SqlParameter PAR_NO = new SqlParameter("@PAR_NO", SqlDbType.Int, 18);
PAR_NO.Value = 0;
sc.Parameters.Add(PAR_NO);


SqlParameter VAHEDFAR = new SqlParameter("@VAHEDFAR", SqlDbType.Int, 4);
VAHEDFAR.Value = 0;
sc.Parameters.Add(VAHEDFAR);


SqlParameter USERCODE = new SqlParameter("@USERCODE", SqlDbType.Int, 18);
USERCODE.Value = 0;
sc.Parameters.Add(USERCODE);


SqlParameter USERNAM = new SqlParameter("@USERNAM", SqlDbType.NVarChar, 50);
USERNAM.Value = "0";
sc.Parameters.Add(USERNAM);


SqlParameter KARBARICD = new SqlParameter("@KARBARICD", SqlDbType.Int, 18);
KARBARICD.Value = 0;
sc.Parameters.Add(KARBARICD);


SqlParameter KARBARINUM = new SqlParameter("@KARBARINUM", SqlDbType.NVarChar, 50);
KARBARINUM.Value = "0";
sc.Parameters.Add(KARBARINUM);


SqlParameter ENSH_TYPE_CD = new SqlParameter("@ENSH_TYPE_CD", SqlDbType.Int, 18);
ENSH_TYPE_CD.Value = 0;
sc.Parameters.Add(ENSH_TYPE_CD);


SqlParameter ENSH_TYPE_NAM = new SqlParameter("@ENSH_TYPE_NAM", SqlDbType.NVarChar, 50);
ENSH_TYPE_NAM.Value = "0";
sc.Parameters.Add(ENSH_TYPE_NAM);


SqlParameter ABSSPER = new SqlParameter("@ABSSPER", SqlDbType.Int);
ABSSPER.Value = 0;
sc.Parameters.Add(ABSSPER);


SqlParameter ABSSAMT = new SqlParameter("@ABSSAMT", SqlDbType.Int, 18);
ABSSAMT.Value = 0;
sc.Parameters.Add(ABSSAMT);


SqlParameter paraAlreadyIn = new SqlParameter("@AlreadyIn", SqlDbType.Int, 2);
paraAlreadyIn.Direction = ParameterDirection.Output;
sc.Parameters.Add(paraAlreadyIn);


try
{
sc.Connection.Open();
sc.ExecuteNonQuery();
nalready=(int)paraAlreadyIn.Value;
}
catch(Exception oException)
{
throw oException;
}


finally
{
sc.Connection.Close();
}
}

Check to make sure that inside your stored procedure and inside your code that all parameters names' match exactly, and that you have that many parameters to add. If you're missing one or your text is mispelled somewhere, you will receive this error also. Check to make sure all @ statements are spelled correctly and are in your stored procedure, along with inside your code.

Also, within your stored procedure, does this line really occur exactly, even with the --?

"--@NAGHDY_TOT numeric(18,0),"

Try taking that out..

I changed stored procedure


ALTER PROCEDURE [dbo].[Insert_VAHED]
@VAHED_NO int,
@ID_FEMAIN numeric(8,0),
@ID_ADDR numeric(8,0),
@GHARM numeric(7,0),
@GHAR numeric(7,0),
@ADD_ID int,
@DATE_IJ nvarchar(50),
@DATE_IJ_F nvarchar(50),
@KOL_ARSE numeric(9,0),
@KOL_AYAN numeric(8,0),
@MOFID numeric(8,0),
@T_VAHED numeric(4,0),
@T_TABAGH numeric(2,0),
@AB_ENSH nvarchar(50),
@T_BLOCK numeric(4,0),
@FA_ENSH nvarchar(50),
@AB_TAFK nvarchar(50),
@MOSHA numeric(8,0),
@FA_TAFk nvarchar(50),
@Z1 numeric(12,0),
@Z2 numeric(12,0),
@Z3 numeric(12,0),
@Z4 numeric(12,0),
@Z5 numeric(12,0),
@Z6 numeric(12,0),
@Z7 numeric(12,0),
@Z8 numeric(12,0),
@Z9 numeric(12,0),
@Z10 numeric(12,0),
@ELAT nvarchar(20),
@ELAT_CD numeric(3,0),
@MN_SHAHR nvarchar(50),
@TOT_DAR numeric(12,0),
@TAKHFIF_NAM nvarchar(50),
@TAKHFIF_CD numeric(18,0),
@GHAR_ZARF numeric(18,0),
@TAKHFIF_AMT numeric(18,0),
@BRANCH_CD numeric(3,0),
@BRNAM nvarchar(50),
@FACD numeric(18,0),
@FANAM nvarchar(50),
@ABNASB nvarchar(50),
@FANASB numeric(18,0),
@ABTOSE numeric(18,0),
@FATOSE numeric(18,0),
@TOTAL_AB numeric(18,0),
@TOTAL_FA numeric(18,0),
@NAGHDY_AB numeric(18,0),
@NAGHDY_FA numeric(18,0),
@NAGHDY_TOT numeric(18,0),
@AGHAMT numeric(18,0),
@AGHAB numeric(18,0),
@AGHFA numeric(18,0),
@AGHTOT numeric(18,0),
@AGHNO numeric(18,0),
@SABT_DATE nvarchar(50),
@SABT_DATE_F nvarchar(50),
@VAHEDASL numeric(4,0),
@VOSDATE nvarchar(50),
@VOSDATEF nvarchar(50),
@PAR_NO numeric(18,0),
@VAHEDFAR numeric(4,0),
@USERCODE numeric(18,0),
@USERNAM nvarchar(50),
@KARBARICD numeric(18,0),
@KARBARINUM nvarchar(50),
@ENSH_TYPE_CD numeric(18,0),
@ENSH_TYPE_NAM nvarchar(50),
@ABSSPER int,
@ABSSAMT numeric(18,0)
AS
BEGIN

INSERT INTO VAHED(VAHED_NO,ID_FEMAIN,ID_ADDR,GHARM,GHAR,ADD_ID,DATE_IJ,DATE_IJ_F,KOL_ARSE,KOL_AYAN,MOFID,MOSHA,T_VAHED,T_BLOCK,T_TABAGH,AB_ENSH,FA_ENSH,AB_TAFK,FA_TAFk,Z1,Z2,Z3,Z4,Z5,Z6,Z7,Z8,Z9,Z10,ELAT,ELAT_CD,MN_SHAHR,TOT_DAR,TAKHFIF_NAM,TAKHFIF_CD,GHAR_ZARF,TAKHFIF_AMT,BRANCH_CD,BRNAM,FACD,FANAM,ABNASB,FANASB,ABTOSE,FATOSE,TOTAL_AB,TOTAL_FA,NAGHDY_AB,NAGHDY_FA,NAGHDY_TOT,AGHAMT,AGHAB,AGHFA,AGHTOT,AGHNO,SABT_DATE,SABT_DATE_F,VOSDATE,VOSDATEF,PAR_NO,VAHEDASL,VAHEDFAR,USERCODE,USERNAM,KARBARICD,KARBARINUM,ENSH_TYPE_CD,ENSH_TYPE_NAM,ABSSPER,ABSSAMT) VALUES (@VAHED_NO,@ID_FEMAIN,@ID_ADDR,@GHARM,@GHAR,@ADD_ID,@DATE_IJ,@DATE_IJ_F,@KOL_ARSE,@KOL_AYAN,@MOFID,@MOSHA,@T_VAHED,@T_BLOCK,@T_TABAGH,@AB_ENSH,@FA_ENSH,@AB_TAFK,@FA_TAFk,@Z1,@Z2,@Z3,@Z4,@Z5,@Z6,@Z7,@Z8,@Z9,@Z10,@ELAT,@ELAT_CD,@MN_SHAHR,@TOT_DAR,@TAKHFIF_NAM,@TAKHFIF_CD,@GHAR_ZARF,@TAKHFIF_AMT,@BRANCH_CD,@BRNAM,@FACD,@FANAM,@ABNASB,@FANASB,@ABTOSE,@FATOSE,@TOTAL_AB,@TOTAL_FA,@NAGHDY_AB,@NAGHDY_FA,@NAGHDY_TOT,@AGHAMT,@AGHAB,@AGHFA,@AGHTOT,@AGHNO,@SABT_DATE,@SABT_DATE_F,@VOSDATE,@VOSDATEF,@PAR_NO,@VAHEDASL,@VAHEDFAR,@USERCODE,@USERNAM,@KARBARICD,@KARBARINUM,@ENSH_TYPE_CD,@ENSH_TYPE_NAM,@ABSSPER,@ABSSAMT)
END

It should work... are you sure all the field types are the same in your stored procedure as they are in the database? int for int, varchar for varchar? It normally wouldn't throw that error though..

maybe try adding "SET NOCOUNT ON" in your stored procedure. See if that works. And if it does, see if ALL values are inserted and which ones are not.

you must passed more parameters then store procedure.

to find additional parameter comment all parameter and uncomment one by one and debug.

- Sam

Simply check the name of the table you have used in the stored procedure you have used for insert and the actual table name.

//your command object's still has old parameter so u have to clear them. u can solve the problem in this wise,

your_command_obj.Parameters.Clear();
your_command_obj.Parametres.Add(new parameters name);

i have a checkbox..
and in database if checkbox true than 1 and otherwise 0 value inserted in the database..
i have insert value but the problem is that
i have a select button when click button how to show checkbox checked or not but we are inserting the value 0,1

how can be show check box checked from (past value )

Start a new post

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.