what is the problem in this code
i have erorr in this line (
string query = "if exists(select Avatar from pets Where Skey = @Skey);
)
string connectionString = WebConfigurationManager.ConnectionStrings["conString"].ConnectionString;
SqlConnection con = new SqlConnection(connectionString);
string query = "if exists(select Avatar from pets Where Skey = @Skey);
query += " begin select Avatar from pets Where Skey = @Skey end";
query += " else begin select Avatar from pets Where Skey = '1' end" ;
SqlCommand cmd = new SqlCommand(query, con);
con.Open();
cmd.Parameters.AddWithValue("@Skey", Request.QueryString["ID"]);
object ReturnImage = cmd.ExecuteScalar();
byte[] photo = (byte[])ReturnImage;
Response.BinaryWrite(photo);
con.Close();