Not Getting Data Back From Stored Proc Call
-
I am passing in the procedure name and a parameter array. The values in the array are correct, yet I'm not getting any data back:
public DataSet ExecuteQueryProc(string sParameterName, SqlParameter[] ParamArray)
{
DataSet oDataSet = new DataSet();SqlConnection oConn = GetConnection(true); if (oConn != null) { SqlCommand oCommand = new SqlCommand(); oCommand.Connection = oConn; oCommand.CommandText = sParameterName; oCommand.CommandType = CommandType.StoredProcedure; oCommand.Parameters.AddRange(ParamArray); SqlDataAdapter oAdapter = new SqlDataAdapter(); oAdapter.SelectCommand = oCommand; oAdapter.Fill(oDataSet); } return oDataSet;
}
Anyone wanna take a stab it this?
Everything makes sense in someone's mind
-
I am passing in the procedure name and a parameter array. The values in the array are correct, yet I'm not getting any data back:
public DataSet ExecuteQueryProc(string sParameterName, SqlParameter[] ParamArray)
{
DataSet oDataSet = new DataSet();SqlConnection oConn = GetConnection(true); if (oConn != null) { SqlCommand oCommand = new SqlCommand(); oCommand.Connection = oConn; oCommand.CommandText = sParameterName; oCommand.CommandType = CommandType.StoredProcedure; oCommand.Parameters.AddRange(ParamArray); SqlDataAdapter oAdapter = new SqlDataAdapter(); oAdapter.SelectCommand = oCommand; oAdapter.Fill(oDataSet); } return oDataSet;
}
Anyone wanna take a stab it this?
Everything makes sense in someone's mind
oConn equaling null would result in no data.
Just because we can; does not mean we should.
-
I am passing in the procedure name and a parameter array. The values in the array are correct, yet I'm not getting any data back:
public DataSet ExecuteQueryProc(string sParameterName, SqlParameter[] ParamArray)
{
DataSet oDataSet = new DataSet();SqlConnection oConn = GetConnection(true); if (oConn != null) { SqlCommand oCommand = new SqlCommand(); oCommand.Connection = oConn; oCommand.CommandText = sParameterName; oCommand.CommandType = CommandType.StoredProcedure; oCommand.Parameters.AddRange(ParamArray); SqlDataAdapter oAdapter = new SqlDataAdapter(); oAdapter.SelectCommand = oCommand; oAdapter.Fill(oDataSet); } return oDataSet;
}
Anyone wanna take a stab it this?
Everything makes sense in someone's mind
Have you tried running the proc in query analyser with the EXACT paramters you are passing? Its often easy to get a trailng space on a string that results in no data, or similar problems. I often just do a bit of code to generate the exact call (with the param values in the correct quites etc), then test it in query analyser.
Bob Ashfield Consultants Ltd