If query exists (syntax error)

phoenixgold

New Member
I have an error in my code.The error in line 4:\[quote\] (string query = "if exists(select Avatar from pets Where Skey = @Skey);)\[/quote\]Here is my code:\[code\]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();\[/code\]
 
Back
Top