Hi, rtCary
Yes you can use if (dataReader.HasRows). Also i will suggest to wrap your code under "using" . Below is the sample code
using (SqlConnection connection = new SqlConnection("xx--Your Connection String—xx"))
{
using (SqlCommand command = new SqlCommand("xx-Your Command--xx", connection))
{
connection.Open();
using (SqlDataReader dataReader = command.ExecuteReader(CommandBehavior.CloseConnection))
{
if (dataReader != null)
if (dataReader.HasRows)
{
//your logic
}
}
}
} The using statement guarantees that resources are properly cleaned up and that they're cleaned up in the most timely manner.
Raghav
CodeASP.NET Community |
My Blog |
jQuery Intellisense in Visual Studio 2008 "Success doesn't come to you…you go to it."--Marva Collins
"Failure is success if we learn from it." Malcolm Forbes
"Success does not come to those who wait . . . and it does not wait for anyone to come to it." Anonymous