Question: I keep getting an error for reader. I just want to be able to return the single value from the reader. Can anyone please help me?

```
        DbProviderFactory factory = DbProviderFactories.GetFactory("System.Data.SqlClient");

        DbConnection conn = factory.CreateConnection();

        conn.ConnectionString = ConfigurationManager.ConnectionStrings["CompanyConnection"].ConnectionString;

        DbCommand comm = conn.CreateCommand();
        comm.CommandText = "getStockPrice";
        comm.CommandType = CommandType.StoredProcedure;

        DbParameter param = comm.CreateParameter();
        param.ParameterName = "@company";
        param.Value = CompanyName;
        param.DbType = DbType.String;
        comm.Parameters.Add(param);
        conn.Open();

        DbDataReader reader = comm.ExecuteReader();
        string stock = reader;
        reader.Close();
        conn.Close();
        return Convert.ToDouble(stock);

```

This is the stored procedure:

```
        @company varchar(50)
    AS
Select stockPrice From Company_t
where companyName = @company;

```

Answer: 
You would have to do something like:

```
string stock = reader.GetString(0);

```

or

```
string stock = reader.GetString(reader.GetOrdinal("stockPrice"));

```

instead of

```
string stock = reader;

```

Edit:

You could use `GetDouble()` instead of `GetString()` and skip the `Convert.ToDouble()`
You can't directly access data in the `DataReader` without reading it. This method won't break your code even in case your query returns no data.

```
DbDataReader reader = comm.ExecuteReader();
string stock = "0";

while (reader.Read())
{
    // get the results of each column
    stock = reader["stockprice"].ToString();
    break;
}
reader.Close();
conn.Close();
return Convert.ToDouble(stock);

```