Is there a way to read some custom return parameters from a stored procedure by name in C#? The iterative way works like this:
SqlDataReader rdr = cmd.ExecuteReader();
if (rdr.HasRows)
{
while (rdr.Read())
{
if (rdr[0] != null)
{
string PARAM1 = rdr[0].ToString();
}
if (rdr[1] != null)
{
string PARAM2 = rdr[1].ToString();
}
if (rdr[2] != null)
{
string PARAM3 = rdr[2].ToString();
}
if (rdr[3] != null)
{
string PARAM4 = rdr[3].ToString();
}
}
}
rdr.Close();
the procedure returns something like this:
SELECT
'value1' AS 'PARAM1',
199 AS 'PARAM2',
'value2' AS 'PARAM3',
'value3' AS 'PARAM4'
RETURN 0
..but that solution is not satisfying to get a param by name or by type.
ReturnValue? Or are you talking about the result set?PARAMxvariables on each loop iteration and that is probably not what you would want.