Using the dataset, if you know that you'll only get one row, you can just access the row directly:
int id = (int)ds.Table["Feedbacks"].Rows[0]["ComfortLevel"];
If you are doing a data aggregation and are looking for only a single value you could further simplify your code to something like this:
SqlCommand objCmd = new SqlCommand("SELECT * FROM dbo.Feedbacks WHERE (FeedbackId = (SELECT MAX(FeedbackID) FROM Feedbacks))", new SqlConnection(StrConnection));
objCmd.Connection.Open();
int id = (int)objCmd.ExecuteScalar();
objCmd.Connection.Close();
if (id < 3)
{
message2.Text = "Contact a tutor";
}
http://msdn.microsoft.com/library/en...calartopic.asp
-
Peter