Procedure or function has too many arguments specified

B

Bill

Hi,

Can anyone help me with this error? It works on the local natwork, but not
on the webhost.
(ive tried everything i can think of... even MS KB 827366)

TIA, Bill.

Error:

System.Data.SqlClient.SqlException: Procedure or function sp_adduser has too
many arguments specified

my code:


public int addUser(string userFirstName, string userLastName, string
userEmail, string userPassword, bool userCMSAccess, bool
userAdministerOthers, bool userMaster, bool userDemo, int userPartner)
{
string[] paramName = new string[9];
object[] paramValue = new object[9];
System.Data.SqlDbType[] paramType = new System.Data.SqlDbType[9];

paramName[0] = "@userFirstName";
paramValue[0] = userFirstName;
paramType[0] = System.Data.SqlDbType.NVarChar;

paramName[1] = "@userLastName";
paramValue[1] = userLastName;
paramType[1] = System.Data.SqlDbType.NVarChar;

paramName[2] = "@userEmail";
paramValue[2] = userEmail;
paramType[2] = System.Data.SqlDbType.NVarChar;

paramName[3] = "@userPassword";
paramValue[3] = userPassword;
paramType[3] = System.Data.SqlDbType.NVarChar;

paramName[4] = "@userCMSAccess";
paramValue[4] = userCMSAccess;
paramType[4] = System.Data.SqlDbType.Bit;

paramName[5] = "@userAdministerOthers";
paramValue[5] = userAdministerOthers;
paramType[5] = System.Data.SqlDbType.Bit;

paramName[6] = "@userMaster";
paramValue[6] = userMaster;
paramType[6] = System.Data.SqlDbType.Bit;

paramName[7] = "@userDemo";
paramValue[7] = userDemo;
paramType[7] = System.Data.SqlDbType.Bit;

paramName[8] = "@userPartner";
paramValue[8] = userPartner;
paramType[8] = System.Data.SqlDbType.Int;

return SaveValuesDBTYPED("sp_addUser",paramName,paramValue,paramType,true);
}


public int SaveValuesDBTYPED(string procedureName,string[]
paramName,object[] paramValue,System.Data.SqlDbType[] paramType,bool
identity)
{
SqlConnection con = new SqlConnection(ConnectionString);

try
{
SqlCommand com = new SqlCommand(procedureName,con);
SqlParameter p = new SqlParameter();
for(int i=0;i<paramName.Length;i++)
{
SqlParameter p = new SqlParameter(paramName,paramType);
p.Value = paramValue;
com.Parameters.Add(p);
}

com.CommandType = CommandType.StoredProcedure;
con.Open();

return int.Parse(com.ExecuteScalar().ToString());
return identity ? int.Parse(com.ExecuteScalar().ToString()) :
com.ExecuteNonQuery();

}
catch(Exception exc)
{
throw exc;
}
finally
{
con.Close();
}
 
J

John Wadie

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.

Actually there is a system stored procedure named "sp_adduser" in SQL
Server, so your best solution would be to provide the fully qualified
procedure name.

Cheers,
John Wadie
 
B

Bill

I ended up change the stored procedure name to a different much more unique
name - using the fully qualified name wasnt an option as the database names
were different locally compare to the web host.

In any case this fixed it - so I am a happy boy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top