Click here to Skip to main content
16,004,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a store procedure like this

SQL
ALTER proc [citrus_usr].[pr_ins_upd_reqdtls](
  @pa_id numeric
, @pa_action varchar(50)
, @pa_req_slip_no varchar(100)
, @pa_req_date datetime
, @pa_boid varchar(16)
, @pa_boname varchar(150)
, @pa_sholder varchar(150)
, @pa_tholder varchar(150)
, @pa_login_name varchar(100)
, @pa_chk_yn smallint
, @pa_rmks varchar(200)
, @pa_error varchar(8000)  output
)
as
begin

...............

and from front end i am calling like this
SQL
cmd.Parameters("@pa_error").Direction = ParameterDirection.Output
cmd.Parameters.Add("@pa_error", SqlDbType.VarChar, 8000)


it is giving error too many arguments specified
--
Posted
Updated 27-Apr-11 3:44am
v2
Comments
jim lahey 27-Apr-11 9:45am    
The clue is definitely in the error message - you're passing too many arguments to the stored procedure, but I can't tell you where or which one because the SqlCommand you've posted isn't complete
Mayur Gujrathiii 27-Apr-11 9:54am    
posted my code
Mayur Gujrathiii 27-Apr-11 9:53am    
Dim Var_StrLoginame As String = Session("LoginName")
Dim cmd As SqlCommand = New SqlCommand
Dim constr As String = ConfigurationManager.AppSettings("PooledConnectionString")
Dim sqlcon As SqlConnection = New SqlConnection(constr)
Dim da As SqlDataAdapter = New SqlDataAdapter("select * from Dis_req_Dtls_MAK", sqlcon)
da.SelectCommand = cmd
cmd.Connection = sqlcon
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "pr_ins_upd_reqdtls"
cmd.Parameters.Clear()
cmd.Parameters.AddWithValue("@pa_action", "SEARCHCHK")
cmd.Parameters.AddWithValue("@pa_tholder", ddlselect.Value)
If (filter.Value = "I") Then
cmd.Parameters.AddWithValue("@pa_boid", hdfilter.Value)
cmd.Parameters.AddWithValue("@pa_req_slip_no", "")
cmd.Parameters.AddWithValue("@pa_req_date", "")
ElseIf (filter.Value = "S") Then
cmd.Parameters.AddWithValue("@pa_boid", "")
cmd.Parameters.AddWithValue("@pa_req_slip_no", hdfilter.Value)
cmd.Parameters.AddWithValue("@pa_req_date", "")
ElseIf (filter.Value = "D") Then
cmd.Parameters.AddWithValue("@pa_boid", "")
cmd.Parameters.AddWithValue("@pa_req_slip_no", "")
cmd.Parameters.AddWithValue("@pa_req_date", hdfilter.Value)
End If
cmd.Parameters.AddWithValue("@pa_login_name", Var_StrLoginame)

'parameters not in use
cmd.Parameters.AddWithValue("@pa_id", 0)
cmd.Parameters.AddWithValue("@pa_boname", "")
cmd.Parameters.AddWithValue("@pa_boname", "")
cmd.Parameters.AddWithValue("@pa_sholder", "")
cmd.Parameters.AddWithValue("@pa_chk_yn", 0)
cmd.Parameters.AddWithValue("@pa_rmks", "")



cmd.Parameters.Add("@pa_error", SqlDbType.VarChar, 8000)
cmd.Parameters("@pa_error").DbType = DbType.AnsiString
cmd.Parameters("@pa_error").Direction = ParameterDirection.Output


'cmd.Parameters.Add("@pa_error", SqlDbType.VarChar, 800, "@pa_error")

'cmd.Parameters("@pa_error").Direction = ParameterDirection.Output

da.Fill(ds, "pr_ins_upd_reqdtls")


If (Not (ds.Tables(0).Rows.Count > 0)) Then

'GridView1.Visible = False
GridView1.DataSource = ds.Tables(0)
GridView1.DataBind()
lblsubheader.Text = "No Records Found"
ElseIf ds.Tables(0).Rows.Count > 0 Then
Dim rowcount As Integer
rowcount = ds.Tables(0).Rows.Count
GridView1.DataSource = ds.Tables(0)
GridView1.DataBind()
' ViewState("dsdata") = ds
lblsubheader.Text = "Records Found, " & rowcount & " "
End If
'Else
'lblsubheader.Text = "Enter Proper Date"
'End If


Catch ex As Exception
Response.Write(ex.Message.ToString())
End Try

1 solution

Wrong! Thats not the way. Your SP has some 12 parameters. You need to pass on all those while calling the stored procedure.

Go here, look at the details:
MSDN: HOW TO: Call SQL Server Stored Procedures in ASP.NET by Using Visual C# .NET[^]
MSDN: HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET[^]
ADO.NET : Using Stored Procedures[^]
 
Share this answer
 
Comments
Mayur Gujrathiii 27-Apr-11 9:52am    
i am calling all but where i am getting error i put it here
Sandeep Mewara 27-Apr-11 9:58am    
If you need proper help, please avoid such things in future. They are misleading.

Now, based on the code you posted, you have done this twice:
cmd.Parameters.AddWithValue("@pa_boname", "")

and thus the parameter count mismatch. Remove one and try.
Mayur Gujrathiii 27-Apr-11 10:04am    
Thanks , i will take care of such silly mistakes
Sandeep Mewara 27-Apr-11 10:06am    
So you say issue resolved?
Mayur Gujrathiii 27-Apr-11 10:09am    
yes dear

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