P
Patreek
Hi,
On the line where I'm assigning RecordCount to be the value of my output
parameter, I'm getting the generic "Object reference not set to an instance
of an object" error. I've isolated it down to this line, as the line of
code commented out just beneath it runs fine. Can anyone see why my
parameter isn't an object? When I grab the command from SQL profiler and
run it in Query Analyzer, I get my output parameter returned with a non-null
value.
Thank you
using (SqlConnection objConn = new SqlConnection(clsData.GetConnStr()))
{
SqlCommand objCmd = new SqlCommand("search", objConn);
objCmd .CommandType = CommandType.StoredProcedure;
//some input parameters defined here
SqlParameter reccount= objCmd.Parameters.Add("@reccount",
SqlDbType.Int);
reccount.Direction = ParameterDirection.Output;
objConn.Open();
ret = oCmd.ExecuteReader(CommandBehavior.CloseConnection);
RecordCount = (int)reccount.Value;
//RecordCount = 5; //no error with that
//etc.
}
On the line where I'm assigning RecordCount to be the value of my output
parameter, I'm getting the generic "Object reference not set to an instance
of an object" error. I've isolated it down to this line, as the line of
code commented out just beneath it runs fine. Can anyone see why my
parameter isn't an object? When I grab the command from SQL profiler and
run it in Query Analyzer, I get my output parameter returned with a non-null
value.
Thank you
using (SqlConnection objConn = new SqlConnection(clsData.GetConnStr()))
{
SqlCommand objCmd = new SqlCommand("search", objConn);
objCmd .CommandType = CommandType.StoredProcedure;
//some input parameters defined here
SqlParameter reccount= objCmd.Parameters.Add("@reccount",
SqlDbType.Int);
reccount.Direction = ParameterDirection.Output;
objConn.Open();
ret = oCmd.ExecuteReader(CommandBehavior.CloseConnection);
RecordCount = (int)reccount.Value;
//RecordCount = 5; //no error with that
//etc.
}