I have to find max value of one table using dataset.
I have written code for that as follows :
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter("select max(FlightBookingID) from dbo.FlightBookingDetails", FlyCon);
da.Fill(ds);
if (ds != null)
{
Session["FBookingID"] = Convert.ToString(ds.Tables[0].Rows[0]["FlightBookingID"]);
}
But its geting error in
Convert.ToString(ds.Tables[0].Rows[0]["FlightBookingID"]);
What changes should i do in above code?
Why can’t you use
SqlCommand.ExecuteScalar?DataSetis very complex class, and you shouldn’t create it just to get one value from the database.