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();
}
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();
}