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.
No comments:
Post a Comment