How can I shorten the below code for if(rdr.read()) sections
protected void Page_Load(object sender, EventArgs e)
{
//Create a connection to our database, using the connection string we added to the Web.Config file
// SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString4"].ConnectionString);
//Create our SQL command to select a random row
SqlCommand cmd = new SqlCommand("SELECT TOP 10 ImagePath FROM ImageInfo ORDER BY id", conn);
cmd.CommandType = CommandType.Text;
//open the connection and send the query using (conn)
{
conn.Open();
SqlDataReader rdr = cmd.ExecuteReader();
i ...
Go to the complete details ...