M
MarSteven
Guest
I have one doubt.
I have 2 dbs
they both use these connection string:
Server=ServerName-QA; Database; db1Name; User ID=sa; Password=thePass
Server=ServerName-QA; Database; db2Name; User ID=sa; Password=thePass
I try to connect those dbs store procedures using this code:
public static string execute(string cnnString, DateTime
date, string storedProcedure)
{
string result = string.Empty;
SqlConnection sqlConnection = new
SqlConnection(cnnString);
try
{
SqlCommand cmd = new SqlCommand();
cmd.CommandText = storedProcedure;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@date", SqlDbType.DateTime).Value = date;
cmd.CommandTimeout = 0;
SqlParameter ouput = new SqlParameter("@ouput", SqlDbType.Int);
ouput.Direction = ParameterDirection.Output;
cmd.Parameters.Add(ouput);
cmd.Connection = sqlConnection;
sqlConnection.Open();
cmd.ExecuteNonQuery();
int resultNumber = int.Parse(cmd.Parameters["@ouput"].Value.ToString());
if (resultNumber == 1 || resultNumber == 0)
result = resultNumber.ToString();
else
result = Texts.error_unknown;
}
catch (Exception ex)
{
sqlConnection.Close();
result = string.Format(Texts.error_storedProcedure, storedProcedure, ex.Message);
}
finally
{
sqlConnection.Close();
}
return result;
}
the store procedures for both dbs I am trying to run have this structure:
the issue is:
whenever I check to run the db1Name store procedure, the output is good
But whenever I check to run the db2Name this message appears:
Procedure or function '' expects parameter '@output', which was not supplied.
do you know a possible solution to that?But when I check to run the db2Name this message appears:
Procedure or function '' expects parameter '@output', which was not supplied.
do you know a possible solution to that?
Continue reading...
I have 2 dbs
they both use these connection string:
Server=ServerName-QA; Database; db1Name; User ID=sa; Password=thePass
Server=ServerName-QA; Database; db2Name; User ID=sa; Password=thePass
I try to connect those dbs store procedures using this code:
public static string execute(string cnnString, DateTime
date, string storedProcedure)
{
string result = string.Empty;
SqlConnection sqlConnection = new
SqlConnection(cnnString);
try
{
SqlCommand cmd = new SqlCommand();
cmd.CommandText = storedProcedure;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@date", SqlDbType.DateTime).Value = date;
cmd.CommandTimeout = 0;
SqlParameter ouput = new SqlParameter("@ouput", SqlDbType.Int);
ouput.Direction = ParameterDirection.Output;
cmd.Parameters.Add(ouput);
cmd.Connection = sqlConnection;
sqlConnection.Open();
cmd.ExecuteNonQuery();
int resultNumber = int.Parse(cmd.Parameters["@ouput"].Value.ToString());
if (resultNumber == 1 || resultNumber == 0)
result = resultNumber.ToString();
else
result = Texts.error_unknown;
}
catch (Exception ex)
{
sqlConnection.Close();
result = string.Format(Texts.error_storedProcedure, storedProcedure, ex.Message);
}
finally
{
sqlConnection.Close();
}
return result;
}
the store procedures for both dbs I am trying to run have this structure:
the issue is:
whenever I check to run the db1Name store procedure, the output is good
But whenever I check to run the db2Name this message appears:
Procedure or function '' expects parameter '@output', which was not supplied.
do you know a possible solution to that?But when I check to run the db2Name this message appears:
Procedure or function '' expects parameter '@output', which was not supplied.
do you know a possible solution to that?
Continue reading...