my plans table has 15 fields, using ExecuteScalar seems to grab the result from the first column only, how do I specify the column name that I want? for example when I run the code below, it will return 1 which is the value in my ID column, but I want plan_rate
column.
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CustomerDataConnectionString"].ConnectionString))
{
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM [dbo].[plans] WHERE age_group = @age_group AND coverage_type = @coverage_type", conn);
cmd.Parameters.AddWithValue("@age_group", dd_ageGroup.Text);
cmd.Parameters.AddWithValue("@coverage_type", dd_coverageType.Text);
Object result = cmd.ExecuteScalar();
if (result != null)
Label1.Text = "Plan rate: $" + result.ToString();
else
Label1.Text = "Plan is not available in this state.";
}