Showing posts with label arguments. Show all posts
Showing posts with label arguments. Show all posts

Sunday, February 26, 2012

Error:Procedure or function CatalogJSummary has too many arguments specified

hello, all

I am using a Stored procedure and calling this in my code in C#.

Here is my procedure:

CatalogJSummary

(

@.SeriesId INT

)

AS

SELECT Games.GameName, Games.Id AS GameId

FROM GameCodes INNER JOIN

Games ON GameCodes.GameId = Games.Id INNER JOIN

MobileSeries ON GameCodes.SeriesId = MobileSeries.Id INNER JOIN

Mobiles ON MobileSeries.Id = Mobiles.SeriesId

GROUP BY Games.GameName, Games.Id, MobileSeries.Id

HAVING (MobileSeries.Id = @.SeriesId)

RETURN

and here is the calling C# code::

public DataSet CatalogJSummary(int sid)

{

SqlConnection cnUnique=new SqlConnection();

cnUnique.ConnectionString=System.Configuration.ConfigurationSettings.AppSettings["jconnection"];

//con.ConnectionString=System.Configuration.ConfigurationSettings.AppSettings["jconnection"];

com.CommandText="CatalogJSummary";

com.CommandType=CommandType.StoredProcedure;

com.Parameters.Add("@.SeriesId",SqlDbType.Int);

com.Parameters["@.SeriesId"].Value=sid;

com.Connection=cnUnique;

// con.Open();

cnUnique.Open();

adp=new SqlDataAdapter();

adp.SelectCommand=com;

DataSet ds1=new DataSet();

adp.Fill(ds1);

cnUnique.Close();

return ds1;

}

but when this code execute,with the parameter passed to stored procedure using this code at runtime, i get the following error::

Procedure or function CatalogJSummary has too many arguments specified.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Procedure or function CatalogJSummary has too many arguments specified.

Source Error:

Line 243:adp.SelectCommand=com; Line 244:DataSet ds1=new DataSet(); Line 245:adp.Fill(ds1); Line 246:cnUnique.Close(); Line 247:return ds1;


Source File: c:\inetpub\wwwroot\mobmasti.catalog\classes\truetonescls.cs Line: 245

Anyone please help me to resolve this error

thanks in advance

There are many options you can try:

1. From SQL Server books online:
If the first three characters of the procedure name are sp_, SQL Server
searches the master database for the procedure. If no qualified procedure name is provided, SQL Server searches for the procedure as if the owner name is dbo. To resolve the stored procedure name as a user-defined stored procedure with the same name as a system stored procedure, provide the fully qualified procedure name.

2. Make sure the field names between your calls and the procedure are the same

3. Make sure you attached the database with the user it was intended to be used with. Otherwise you may not have sufficient rights and this message will show up.

Friday, February 24, 2012

error: Too many arguments specified

Error:Too Many Arguments Specified
Posted: 03-03-2005 05:03 AM
Hi,
I'm pretty new to ASP.NET so I'm having some problems
I'm trying to insert a users registration info into the DB using a Stored
Proc but for some reason it won't work
When i run the Sproc in query analyser it seems to be ok with it but when i
run the asp pages it lets me enter the info then when i submit it gives me
the Too many Arguments Specified error
here's the code for the proc
CREATE PROCEDURE [dbo].[Toregister]
(
@.firstname varchar(20),
@.lastname varchar(20),
@.address varchar(20),
@.town varchar(20),
@.county varchar(20),
@.postcode varchar(10),
@.telno varchar(10),
@.email varchar(20),
@.username varchar(20),
@.password varchar(20)
)
AS
insert into t_user
(firstname,lastname,address,town,county,
postcode,telno,email,username,passwo
rd)
values
(@.firstname,@.lastname,@.address,@.town,@.co
unty,@.postcode,@.telno,@.email,@.userna
me,@.password)
GO
and here's the code in my aspx file for adding the parameters
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Save.Click
SqlCommand1.Parameters.Add("@.firstname", txtFirstname.Text)
SqlCommand1.Parameters.Add("@.lastname", txtSurname.Text)
SqlCommand1.Parameters.Add("@.address", txtAddress.Text)
SqlCommand1.Parameters.Add("@.town", txtTown.Text)
SqlCommand1.Parameters.Add("@.county", txtCounty.Text)
SqlCommand1.Parameters.Add("@.postcode", txtPostcode.Text)
SqlCommand1.Parameters.Add("@.telno", txtTelno.Text)
SqlCommand1.Parameters.Add("@.email", txtEmail.Text)
SqlCommand1.Parameters.Add("@.username", txtUsername.Text)
SqlCommand1.Parameters.Add("@.password", txtPassword.Text)
SqlConnection1.Open()
SqlCommand1.ExecuteNonQuery()
End Sub
and just for good measure here's the result from the DB profiler when I run
the asp
exec [Toregister] @.firstname = default, @.lastname = default, @.address =
default, @.town = default, @.county = default, @.postcode = default, @.telno =
default, @.email = default, @.username = default, @.password = default,
@.firstname = N'Neil', @.lastname = N'Patel', @.address = N'28 my street, @.town
= N'mytown', @.county = N'mycounty', @.postcode = N'mypostcd', @.telno =
N'01234567890, @.email = N'neil_pat@.email.com', @.username = N'neilpat',
@.password = N'neil'
I really can't see where this is going wrong
Anny suggestions welcomeMaybe the parameters already exist in the SqlParameterCollection (Look at
where SqlCommand1 is created).
Have you tried... (Warning I am not a .net programmer so my syntax may be
off).
SqlCommand1.Parameters("@.firstname").Value = txtFirstname.Text
SqlCommand1.Parameters("@.lastname").Value = txtSurname.Text
SqlCommand1.Parameters("@.address").Value = txtAddress.Text
SqlCommand1.Parameters("@.town").Value = txtTown.Text
SqlCommand1.Parameters("@.county").Value = txtCounty.Text
SqlCommand1.Parameters("@.postcode").Value = txtPostcode.Text
SqlCommand1.Parameters("@.telno").Value = txtTelno.Text
SqlCommand1.Parameters("@.email").Value = txtEmail.Text
SqlCommand1.Parameters("@.username").Value = txtUsername.Text
SqlCommand1.Parameters("@.password").Value = txtPassword.Text
"neil_pat" wrote:

> Error:Too Many Arguments Specified
> Posted: 03-03-2005 05:03 AM
> Hi,
> I'm pretty new to ASP.NET so I'm having some problems
> I'm trying to insert a users registration info into the DB using a Stored
> Proc but for some reason it won't work
> When i run the Sproc in query analyser it seems to be ok with it but when
i
> run the asp pages it lets me enter the info then when i submit it gives me
> the Too many Arguments Specified error
> here's the code for the proc
> CREATE PROCEDURE [dbo].[Toregister]
> (
> @.firstname varchar(20),
> @.lastname varchar(20),
> @.address varchar(20),
> @.town varchar(20),
> @.county varchar(20),
> @.postcode varchar(10),
> @.telno varchar(10),
> @.email varchar(20),
> @.username varchar(20),
> @.password varchar(20)
> )
> AS
> insert into t_user
> (firstname,lastname,address,town,county,
postcode,telno,email,username,pass
word)
> values
> (@.firstname,@.lastname,@.address,@.town,@.co
unty,@.postcode,@.telno,@.email,@.user
name,@.password)
> GO
> and here's the code in my aspx file for adding the parameters
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Save.Click
>
> SqlCommand1.Parameters.Add("@.firstname", txtFirstname.Text)
> SqlCommand1.Parameters.Add("@.lastname", txtSurname.Text)
> SqlCommand1.Parameters.Add("@.address", txtAddress.Text)
> SqlCommand1.Parameters.Add("@.town", txtTown.Text)
> SqlCommand1.Parameters.Add("@.county", txtCounty.Text)
> SqlCommand1.Parameters.Add("@.postcode", txtPostcode.Text)
> SqlCommand1.Parameters.Add("@.telno", txtTelno.Text)
> SqlCommand1.Parameters.Add("@.email", txtEmail.Text)
> SqlCommand1.Parameters.Add("@.username", txtUsername.Text)
> SqlCommand1.Parameters.Add("@.password", txtPassword.Text)
> SqlConnection1.Open()
> SqlCommand1.ExecuteNonQuery()
> End Sub
>
> and just for good measure here's the result from the DB profiler when I ru
n
> the asp
> exec [Toregister] @.firstname = default, @.lastname = default, @.address =
> default, @.town = default, @.county = default, @.postcode = default, @.telno =
> default, @.email = default, @.username = default, @.password = default,
> @.firstname = N'Neil', @.lastname = N'Patel', @.address = N'28 my street, @.to
wn
> = N'mytown', @.county = N'mycounty', @.postcode = N'mypostcd', @.telno =
> N'01234567890, @.email = N'neil_pat@.email.com', @.username = N'neilpat',
> @.password = N'neil'
> I really can't see where this is going wrong
> Anny suggestions welcome
>

error: too many arguments specified

Error:Too Many Arguments Specified
Posted: 03-03-2005 05:03 AM
Hi,
I'm pretty new to ASP.NET so I'm having some problems
I'm trying to insert a users registration info into the DB using a Stored
Proc but for some reason it won't work
When i run the Sproc in query analyser it seems to be ok with it but when i
run the asp pages it lets me enter the info then when i submit it gives me
the Too many Arguments Specified error
here's the code for the proc
CREATE PROCEDURE [dbo].[Toregister]
(
@.firstname varchar(20),
@.lastname varchar(20),
@.address varchar(20),
@.town varchar(20),
@.county varchar(20),
@.postcode varchar(10),
@.telno varchar(10),
@.email varchar(20),
@.username varchar(20),
@.password varchar(20)
)
AS
insert into t_user
(firstname,lastname,address,town,county,
postcode,telno,email,username,passwo
rd)
values
(@.firstname,@.lastname,@.address,@.town,@.co
unty,@.postcode,@.telno,@.email,@.userna
me,@.password)
GO
and here's the code in my aspx file for adding the parameters
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Save.Click
SqlCommand1.Parameters.Add("@.firstname", txtFirstname.Text)
SqlCommand1.Parameters.Add("@.lastname", txtSurname.Text)
SqlCommand1.Parameters.Add("@.address", txtAddress.Text)
SqlCommand1.Parameters.Add("@.town", txtTown.Text)
SqlCommand1.Parameters.Add("@.county", txtCounty.Text)
SqlCommand1.Parameters.Add("@.postcode", txtPostcode.Text)
SqlCommand1.Parameters.Add("@.telno", txtTelno.Text)
SqlCommand1.Parameters.Add("@.email", txtEmail.Text)
SqlCommand1.Parameters.Add("@.username", txtUsername.Text)
SqlCommand1.Parameters.Add("@.password", txtPassword.Text)
SqlConnection1.Open()
SqlCommand1.ExecuteNonQuery()
End Sub
and just for good measure here's the result from the DB profiler when I run
the asp
exec [Toregister] @.firstname = default, @.lastname = default, @.address =
default, @.town = default, @.county = default, @.postcode = default, @.telno =
default, @.email = default, @.username = default, @.password = default,
@.firstname = N'Neil', @.lastname = N'Patel', @.address = N'28 my street, @.town
= N'mytown', @.county = N'mycounty', @.postcode = N'mypostcd', @.telno =
N'01234567890, @.email = N'neil_pat@.email.com', @.username = N'neilpat',
@.password = N'neil'
I really can't see where this is going wrong
Anny suggestions welcomeActually there are only 10 parameters to be passed.
exec [Toregister] @.firstname = default, @.lastname = default, @.address =
default, @.town = default, @.county = default, @.postcode = default,
@.telno
= default, @.email = default, @.username = default, @.password = default,
@.firstname = N'Neil', @.lastname = N'Patel', @.address = N'28 my street,
@.town = N'mytown', @.county = N'mycounty', @.postcode = N'mypostcd',
@.telno = N'01234567890, @.email = N'neil_...@.email.com', @.username =
N'neilpat', @.password = N'neil'
You passed more than 10
Madhivanan|||Look at the profiler trace. It is passing all the parameters as default
folowed by all the parameters with values - hence 20 parameters instead of 1
0.
I suspect when you build the command you are getting the parameters for the
sp then adding them again.
"neil_pat" wrote:

> Error:Too Many Arguments Specified
> Posted: 03-03-2005 05:03 AM
> Hi,
> I'm pretty new to ASP.NET so I'm having some problems
> I'm trying to insert a users registration info into the DB using a Stored
> Proc but for some reason it won't work
> When i run the Sproc in query analyser it seems to be ok with it but when
i
> run the asp pages it lets me enter the info then when i submit it gives me
> the Too many Arguments Specified error
> here's the code for the proc
> CREATE PROCEDURE [dbo].[Toregister]
> (
> @.firstname varchar(20),
> @.lastname varchar(20),
> @.address varchar(20),
> @.town varchar(20),
> @.county varchar(20),
> @.postcode varchar(10),
> @.telno varchar(10),
> @.email varchar(20),
> @.username varchar(20),
> @.password varchar(20)
> )
> AS
> insert into t_user
> (firstname,lastname,address,town,county,
postcode,telno,email,username,pass
word)
> values
> (@.firstname,@.lastname,@.address,@.town,@.co
unty,@.postcode,@.telno,@.email,@.user
name,@.password)
> GO
> and here's the code in my aspx file for adding the parameters
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Save.Click
>
> SqlCommand1.Parameters.Add("@.firstname", txtFirstname.Text)
> SqlCommand1.Parameters.Add("@.lastname", txtSurname.Text)
> SqlCommand1.Parameters.Add("@.address", txtAddress.Text)
> SqlCommand1.Parameters.Add("@.town", txtTown.Text)
> SqlCommand1.Parameters.Add("@.county", txtCounty.Text)
> SqlCommand1.Parameters.Add("@.postcode", txtPostcode.Text)
> SqlCommand1.Parameters.Add("@.telno", txtTelno.Text)
> SqlCommand1.Parameters.Add("@.email", txtEmail.Text)
> SqlCommand1.Parameters.Add("@.username", txtUsername.Text)
> SqlCommand1.Parameters.Add("@.password", txtPassword.Text)
> SqlConnection1.Open()
> SqlCommand1.ExecuteNonQuery()
> End Sub
>
> and just for good measure here's the result from the DB profiler when I ru
n
> the asp
> exec [Toregister] @.firstname = default, @.lastname = default, @.address =
> default, @.town = default, @.county = default, @.postcode = default, @.telno =
> default, @.email = default, @.username = default, @.password = default,
> @.firstname = N'Neil', @.lastname = N'Patel', @.address = N'28 my street, @.to
wn
> = N'mytown', @.county = N'mycounty', @.postcode = N'mypostcd', @.telno =
> N'01234567890, @.email = N'neil_pat@.email.com', @.username = N'neilpat',
> @.password = N'neil'
> I really can't see where this is going wrong
> Anny suggestions welcome
>|||Could you just explain that? iDo you mean that its counting each one
seprately i.e. 20 instead of 10?
How do i rectify this?
"Madhivanan" wrote:

> Actually there are only 10 parameters to be passed.
> exec [Toregister] @.firstname = default, @.lastname = default, @.address =
> default, @.town = default, @.county = default, @.postcode = default,
> @.telno
> = default, @.email = default, @.username = default, @.password = default,
> @.firstname = N'Neil', @.lastname = N'Patel', @.address = N'28 my street,
> @.town = N'mytown', @.county = N'mycounty', @.postcode = N'mypostcd',
> @.telno = N'01234567890, @.email = N'neil_...@.email.com', @.username =
> N'neilpat', @.password = N'neil'
> You passed more than 10
> Madhivanan
>|||Sorry I'm a bit of a beginer.
Which bit of my code do i need to edit to stop this?
"Nigel Rivett" wrote:
> Look at the profiler trace. It is passing all the parameters as default
> folowed by all the parameters with values - hence 20 parameters instead of
10.
> I suspect when you build the command you are getting the parameters for th
e
> sp then adding them again.
> "neil_pat" wrote:
>|||Have a look at
http://www.mindsdoor.net/DOTNET/DotNetDBAccess.html
It gives a database access layer and includes creation of all the objects.
I suspect you are binding sqlcommand1 to the sp before adding the parameters
.
"neil_pat" wrote:
> Sorry I'm a bit of a beginer.
> Which bit of my code do i need to edit to stop this?
> "Nigel Rivett" wrote:
>|||Remove all the fields with default values
Madhivanan|||I managed to sort it out now.
VS.net was adding default parameters automatically which i removed and it
works fine now
Thanks
"neil_pat" wrote:

> Error:Too Many Arguments Specified
> Posted: 03-03-2005 05:03 AM
> Hi,
> I'm pretty new to ASP.NET so I'm having some problems
> I'm trying to insert a users registration info into the DB using a Stored
> Proc but for some reason it won't work
> When i run the Sproc in query analyser it seems to be ok with it but when
i
> run the asp pages it lets me enter the info then when i submit it gives me
> the Too many Arguments Specified error
> here's the code for the proc
> CREATE PROCEDURE [dbo].[Toregister]
> (
> @.firstname varchar(20),
> @.lastname varchar(20),
> @.address varchar(20),
> @.town varchar(20),
> @.county varchar(20),
> @.postcode varchar(10),
> @.telno varchar(10),
> @.email varchar(20),
> @.username varchar(20),
> @.password varchar(20)
> )
> AS
> insert into t_user
> (firstname,lastname,address,town,county,
postcode,telno,email,username,pass
word)
> values
> (@.firstname,@.lastname,@.address,@.town,@.co
unty,@.postcode,@.telno,@.email,@.user
name,@.password)
> GO
> and here's the code in my aspx file for adding the parameters
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles Save.Click
>
> SqlCommand1.Parameters.Add("@.firstname", txtFirstname.Text)
> SqlCommand1.Parameters.Add("@.lastname", txtSurname.Text)
> SqlCommand1.Parameters.Add("@.address", txtAddress.Text)
> SqlCommand1.Parameters.Add("@.town", txtTown.Text)
> SqlCommand1.Parameters.Add("@.county", txtCounty.Text)
> SqlCommand1.Parameters.Add("@.postcode", txtPostcode.Text)
> SqlCommand1.Parameters.Add("@.telno", txtTelno.Text)
> SqlCommand1.Parameters.Add("@.email", txtEmail.Text)
> SqlCommand1.Parameters.Add("@.username", txtUsername.Text)
> SqlCommand1.Parameters.Add("@.password", txtPassword.Text)
> SqlConnection1.Open()
> SqlCommand1.ExecuteNonQuery()
> End Sub
>
> and just for good measure here's the result from the DB profiler when I ru
n
> the asp
> exec [Toregister] @.firstname = default, @.lastname = default, @.address =
> default, @.town = default, @.county = default, @.postcode = default, @.telno =
> default, @.email = default, @.username = default, @.password = default,
> @.firstname = N'Neil', @.lastname = N'Patel', @.address = N'28 my street, @.to
wn
> = N'mytown', @.county = N'mycounty', @.postcode = N'mypostcd', @.telno =
> N'01234567890, @.email = N'neil_pat@.email.com', @.username = N'neilpat',
> @.password = N'neil'
> I really can't see where this is going wrong
> Anny suggestions welcome
>|||I've sorted it now
VS.Net was adding default parameters automatically. I've removed them and it
works fine now
"Nigel Rivett" wrote:
> Have a look at
> http://www.mindsdoor.net/DOTNET/DotNetDBAccess.html
> It gives a database access layer and includes creation of all the objects.
> I suspect you are binding sqlcommand1 to the sp before adding the paramete
rs.
> "neil_pat" wrote:
>