I am having trouble calling the following stored procedure. When I call ExecuteReader, I am getting the error 'Incorrect syntax near 'GetAverages2'. I can create the stored procedure and call it from TSQL. I can't seem to get it working from ADO:
CREATE PROCEDURE GetAverages2
@CompanySize INT,
@Q1 FLOAT OUT,
@Q2 FLOAT OUT
AS
SELECT @Q1 = 1, @Q2 = 2
GO
string connectionString = ConfigurationManager.ConnectionStrings["MyDbConnection"].ConnectionString;
using (SqlConnection connection = new SqlConnection(connectionString))
{
using (SqlCommand command = new SqlCommand("GetAverages2", connection))
{
command.Parameters.Add("@CompanySize", System.Data.SqlDbType.Int).Value = int.Parse(Request.QueryString["CompanySizeId"]);
command.Parameters.Add("@Q1", System.Data.SqlDbType.Float).Direction = System.Data.ParameterDirection.Output;
command.Parameters.Add("@Q2", System.Data.SqlDbType.Float).Direction = System.Data.ParameterDirection.Output;
connection.Open();
SqlDataReader reader = command.ExecuteReader();