W
weird0
I get the this error when i perform the operation. Any reason why? I
am trying to execute a stored procedure. Then, set its parameters in
getCustomer_Account().Call them in an aspx page;
private static Object ExecuteSP(Object[] argArray)
{
SqlCommand cmd = new SqlCommand();
Object returnValue;
int prmCount = (int)argArray[1];
cmd.CommandText = (string)argArray[2];
cmd.CommandType = CommandType.StoredProcedure;
for (int j = 0, i = 3; j < prmCount; i += 4, j++)
{
SqlParameter myPrm = new
SqlParameter((string)argArray,
(SqlDbType)argArray[i + 1],
(int)argArray[i
+ 2]);
myPrm.Value = argArray[i + 3];
cmd.Parameters.Add(myPrm);
}
SqlConnection sqlConnection1 = new
SqlConnection(connectionSring);
cmd.Connection = sqlConnection1;
sqlConnection1.Open();
if ((int)argArray[0] == 0)
returnValue = cmd.ExecuteNonQuery();
else if ((int)argArray[0] == 1)
returnValue = cmd.ExecuteScalar();
else
returnValue =
cmd.ExecuteReader(CommandBehavior.CloseConnection);
sqlConnection1.Close();
return returnValue;
}
public static bool getCustomerAccount_Status(string userName)
{
Object[] prms = new Object[7];
prms[0]=1;
prms[1] = 1;
prms[2] = "GET_ACCOUNT_STATUS";
prms[3]="@username";
prms[4]=SqlDbType.VarChar;
prms[5] =16;
prms[6]=userName;
Object returnValue = ExecuteSP(prms);
bool myvar=(bool)returnValue; // Line of Error
return myvar;
}
am trying to execute a stored procedure. Then, set its parameters in
getCustomer_Account().Call them in an aspx page;
private static Object ExecuteSP(Object[] argArray)
{
SqlCommand cmd = new SqlCommand();
Object returnValue;
int prmCount = (int)argArray[1];
cmd.CommandText = (string)argArray[2];
cmd.CommandType = CommandType.StoredProcedure;
for (int j = 0, i = 3; j < prmCount; i += 4, j++)
{
SqlParameter myPrm = new
SqlParameter((string)argArray,
(SqlDbType)argArray[i + 1],
(int)argArray[i
+ 2]);
myPrm.Value = argArray[i + 3];
cmd.Parameters.Add(myPrm);
}
SqlConnection sqlConnection1 = new
SqlConnection(connectionSring);
cmd.Connection = sqlConnection1;
sqlConnection1.Open();
if ((int)argArray[0] == 0)
returnValue = cmd.ExecuteNonQuery();
else if ((int)argArray[0] == 1)
returnValue = cmd.ExecuteScalar();
else
returnValue =
cmd.ExecuteReader(CommandBehavior.CloseConnection);
sqlConnection1.Close();
return returnValue;
}
public static bool getCustomerAccount_Status(string userName)
{
Object[] prms = new Object[7];
prms[0]=1;
prms[1] = 1;
prms[2] = "GET_ACCOUNT_STATUS";
prms[3]="@username";
prms[4]=SqlDbType.VarChar;
prms[5] =16;
prms[6]=userName;
Object returnValue = ExecuteSP(prms);
bool myvar=(bool)returnValue; // Line of Error
return myvar;
}