J
Jordan
What I'm trying to do is exectue a stored procedure that returns some
records along with an additional RETURN value. The code is below:
***
SqlConnection Conn = new SqlConnection
(System.Configuration.ConfigurationSettings.AppSettings["MyConn"]);
SqlCommand Cmd = new SqlCommand("spMySP", Conn);
Cmd.CommandType = CommandType.StoredProcedure; Cmd.Parameters.Add (new
SqlParameter("@RowCount", SqlDbType.Int));
Cmd.Parameters["@RowCount"].Direction = ParameterDirection.ReturnValue;
Cmd.Parameters.Add (new SqlParameter("@Parm1", SqlDbType.VarChar, 5));
Cmd.Parameters["@Parm1"].Value = Parm1;
Conn.Open(); SqlDataReader DR = Cmd.ExecuteReader();
Message.Text = Cmd.Parameters["@RowCount"].Value.ToString(); !!!!
***
The problem (i.e. bug) is that I can do either get the results, or get the
return value, but not both. When I have the SELECT statement in the Stored
Proc, it runs and I can bind the DataReader results to a Repeater, but when
then I get a compile error on the line marked above with "!!!!." If I
comment out the line, it works. On the otherhand, if I comment out the
SELECT statement in my Stored Proc, everything compiles and I can see my
return value in the <asp:label id="Message"> field. WHAT THE ...?
Any ideas?
j
records along with an additional RETURN value. The code is below:
***
SqlConnection Conn = new SqlConnection
(System.Configuration.ConfigurationSettings.AppSettings["MyConn"]);
SqlCommand Cmd = new SqlCommand("spMySP", Conn);
Cmd.CommandType = CommandType.StoredProcedure; Cmd.Parameters.Add (new
SqlParameter("@RowCount", SqlDbType.Int));
Cmd.Parameters["@RowCount"].Direction = ParameterDirection.ReturnValue;
Cmd.Parameters.Add (new SqlParameter("@Parm1", SqlDbType.VarChar, 5));
Cmd.Parameters["@Parm1"].Value = Parm1;
Conn.Open(); SqlDataReader DR = Cmd.ExecuteReader();
Message.Text = Cmd.Parameters["@RowCount"].Value.ToString(); !!!!
***
The problem (i.e. bug) is that I can do either get the results, or get the
return value, but not both. When I have the SELECT statement in the Stored
Proc, it runs and I can bind the DataReader results to a Repeater, but when
then I get a compile error on the line marked above with "!!!!." If I
comment out the line, it works. On the otherhand, if I comment out the
SELECT statement in my Stored Proc, everything compiles and I can see my
return value in the <asp:label id="Message"> field. WHAT THE ...?
Any ideas?
j