Anil Sharma

Anil Sharma

  • NA
  • 29
  • 15k

Procedure expects parameter which was not supplied

Feb 25 2020 7:34 AM
I try to through this code
  1. try  
  2. {  
  3. SqlCommand cmd = new SqlCommand("dbo.generate_loan_entry", connect);  
  4. cmd.CommandType = CommandType.StoredProcedure;  
  5. cmd.Parameters.AddWithValue("@farmer_code", party_code.Text);  
  6. cmd.Parameters.AddWithValue("@ticket_no", ticket_no.Text);  
  7. cmd.Parameters.AddWithValue("@total_loan", adj_loan);  
  8. connect.Open();  
  9. cmd.ExecuteNonQuery();  
  10. connect.Close();  
  11. }  
  12. catch (Exception ex)  
  13. {  
  14. Response.Write("<script>alert('" + ex.Message + "')</script>");  
  15. }  
  16. finally  
  17. { }  
My procedure is
  1. ALTER PROCEDURE [dbo].[generate_loan_entry](@farmer_cd nvarchar(6),    
  2. @ticket_no int,    
  3. @total_loan int)    
  4. -- Add the parameters for the stored procedure here    
  5. AS    
  6. BEGIN    
  7. -- SET NOCOUNT ON added to prevent extra result sets from    
  8. -- interfering with SELECT statements.    
  9. SET NOCOUNT ON;    
  10. --DECLARE THE VARIABLES FOR HOLDING DATA.    
  11. DECLARE @v_account_code INT,    
  12. @vloan_amount numeric(8,2),    
  13. @vadj_loan numeric(8,2),    
  14. @vloan_deduct numeric(8,2),    
  15. @vdeducted_loan numeric(8,2);    
  16. --DECLARE AND SET COUNTER.    
  17. DECLARE @Counter INT    
  18. SET @Counter = 1    
  19. --DECLARE THE CURSOR FOR A QUERY.    
  20. DECLARE C1 CURSOR READ_ONLY    
  21. FOR    
  22. SELECT account_code,sum(DEBIT_AMOUNT-CREDIT_AMOUNT)    
  23. FROM FA_BALANCE_MASTER    
  24. WHERE ACCOUNT_CODE IN (211068,211069) AND PARTY_CODE = @farmer_cd    
  25. AND YYYYMM >= (Select year(start_date) from fa_company_detail )    
  26. group by account_code;    
  27. --OPEN CURSOR.    
  28. OPEN C1;    
  29. --FETCH THE RECORD INTO THE VARIABLES.    
  30. FETCH NEXT FROM C1 INTO @v_account_code,@vloan_amount;    
  31. --LOOP UNTIL RECORDS ARE AVAILABLE.    
  32. WHILE @@FETCH_STATUS = 0    
  33. Begin    
  34. -- Insert statements for procedure here    
  35. SELECT @vloan_deduct = SUM(adjusted_amount)    
  36. FROM CA_LOAN_DEDUCTION    
  37. WHERE ACCOUNT_CODE = @v_account_code    
  38. AND PARTY_CODE = @farmer_cd AND isnull(voc_auth_flag,'N') = 'N';    
  39. if (@vloan_deduct > 0.0 )    
  40. begin    
  41. select @vloan_amount = @vloan_amount - @vloan_deduct;    
  42. end ;    
  43. IF (@vloan_amount < isnull(@total_loan,0) - isnull(@vadj_loan,0))    
  44. begin    
  45. select @vdeducted_loan = @vloan_amount ;    
  46. end;    
  47. ELSE    
  48. begin    
  49. select @vdeducted_loan = isnull(@total_loan,0) - isnull(@vadj_loan,0);    
  50. end;    
  51. FETCH NEXT FROM C1 INTO @v_account_code,@vloan_amount;    
  52. IF @vdeducted_loan > 0    
  53. begin    
  54. INSERT INTO CA_LOAN_DEDUCTION VALUES(    
  55. @ticket_no,@v_account_code,@farmer_cd,@vloan_amount,@vdeducted_loan,null,'N');    
  56. end;    
  57. set @vadj_loan = @vadj_loan + @vdeducted_loan;    
  58. end;    
  59. close C1;    
  60. DEALLOCATE C1;    
  61. END; 
please suggest what is the problem. this procedure running through execute procedure i check it

Answers (3)