Click here to Skip to main content
15,900,724 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all

Please can anyone check this code and please let me know where i am going wrong.i am not able
to identify. The rooror says update fails in EMRUPl_Client_Insert.

Please help. Below is my c# code and stored procedure for insert and update.

Thanks
Posted
Updated 19-Jul-13 3:39am
v3
Comments
You should debug your code and find out the exact line, which is throwing the exception.
babli3 4-Jul-13 16:11pm    
Ok I will thanks
jaideepsinh 5-Jul-13 1:45am    
debug your code and find out the exact line, which is throwing the error and paste that code here.
babli3 5-Jul-13 5:15am    
When i debugged this exception i got
" Procedure or function IMS_NB_EMRUP_Client_Insert has too many arguments specified"...


Thanks
Adarsh chauhan 5-Jul-13 3:24am    
doesn't look like there is any error with SP 'IMS_NB_EMRUP_Client_Insert'.
I agree with Tadit and jaideep, debug your code to find out the exact problem.

Remove below line of code and check again.

C#
theCmd.Parameters.AddWithValue("@city", _city);
                       theCmd.Parameters.AddWithValue("@state", _state);
                       theCmd.Parameters.AddWithValue("@occupation", _occupation);
                       theCmd.Parameters.AddWithValue("@status", _status);
                       theCmd.Parameters.AddWithValue("@ethnoracial", _ethnoracial);
                       theCmd.Parameters.AddWithValue("@interpretter", _interpretter);
                       theCmd.Parameters.AddWithValue("@monthlyincome", _monthlyincome);
                       theCmd.Parameters.AddWithValue("@referralsource", _referralsource);
                       theCmd.Parameters.AddWithValue("@pricelevel", _pricelevel);
                       theCmd.Parameters.AddWithValue("@userlist1", _userlist1);
                       theCmd.Parameters.AddWithValue("@userlist3", _userlist3);
                       theCmd.Parameters.AddWithValue("@userlist4", _userlist4);
                       theCmd.Parameters.AddWithValue("@userlist5", _userlist5);
                       theCmd.Parameters.AddWithValue("@usertext11", _usertext11);
                       theCmd.Parameters.AddWithValue("@usertext12", _usertext12);
                       theCmd.Parameters.AddWithValue("@usertext13", _usertext13);
                       theCmd.Parameters.AddWithValue("@usertext14", _usertext14);
                       theCmd.Parameters.AddWithValue("@usertext15", _usertext15);
                       theCmd.Parameters.AddWithValue("@usertext16", _usertext16);
                       theCmd.Parameters.AddWithValue("@usertext17", _usertext17);
                       theCmd.Parameters.AddWithValue("@usertext18", _usertext18);
                       theCmd.Parameters.AddWithValue("@usertext19", _usertext19);
                       theCmd.Parameters.AddWithValue("@usertext20", _usertext20);



the problem is that your procedure takes 13 parameters but you are adding additional 23 or more parameters.

Hopes this should resovle your porblem
 
Share this answer
 
Comments
babli3 5-Jul-13 5:26am    
But my table has all 23 parameters ...will it make any difference if my table has 23 parametrs...sorry i am a fresher...thanks
babli3 5-Jul-13 5:29am    
ok thanks i am going to remove them and run the code again....thank you
babli3 5-Jul-13 6:52am    
Thank you so much
Procedure or function IMS_NB_EMRUP_Client_Insert has too many arguments specified"...
you get this error it means math your parameter which you pass to you store procedure.

And it is also saw in your code in you store procedure there is only 13 parameter and you pass more then 13 parameter it must be same.
 
Share this answer
 
Comments
babli3 5-Jul-13 5:29am    
ok thanks i am going to remove them and run the code again....
jaideepsinh 5-Jul-13 5:39am    
If you want to pass all that 23 parameter add missing parameter in to your store procedure and then run.
Please accept as answer and vote if solve you problem.
babli3 5-Jul-13 6:52am    
Thank you so much
Hi,

as i already mentioned in my comment..
your stored procedures take 13 input parameters
( @PointId bigint, @emrClientId char(25),
@RegisteredOn datetime, @LastUpdated datetime,
@NewAcceptorDate datetime,
@CurrentMethod char(25),
@Dob datetime, @DobType char(10),
@PregnanciesDemo1 smallint,
@ChildrenDemo2 smallint,
@AbortionsDemo3 smallint,
@EducationDemo4 smallint,
@Sex smallint,
)
but you are passing about 36 (see your "theCmd.Parameters.AddWithValue" statements) . thats why it is giving exception. Pass only the required parameters and your prob. will be solved. and to make sure that this is the prob. execute your sp in sql server with inputs.. and you will be sure that its the prob.

and about your question that " But my table has all 23 parameters ...will it make any difference if my table has 23 parametrs"
I would like to tell you that your insert procedure will only insert the data into those columns for which your are passing values (but only if other columns for which you are not passing values allow null)

if your requirement is to insert data to all columns then add parameters to your SP otherwise remove extra parameters from your code.

comment extra "theCmd.Parameters.AddWithValue" statements and run your code.. it should resolve your prob.
 
Share this answer
 
Comments
babli3 5-Jul-13 6:52am    
Thank you so much
Adarsh chauhan 5-Jul-13 6:54am    
you are most welcome...I am happy that your prob. is solved.
provi 777 19-Jul-13 9:53am    
match your parameter which you pass to you store procedure

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900