Here is the code:
public FileContentResult Foto()
{
byte[] byte_image = null;
string query = "SELECT * FROM Tabela WHERE Coluna = @Parameter";
using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
using (var command = new SqlCommand(query, connection))
{
command.Parameters.AddWithValue("@Parameter", User.Identity.Name);
connection.Open();
using (var reader = command.ExecuteReader())
{
if (reader.Read())
{
if (!Convert.IsDBNull(reader["Byte_Image"]))
{
byte_image = (byte[])reader["Byte_Image"];
}
else
{
//Segundo select aqui
string query = "SELECT * FROM Tabela1 WHERE Coluna1 = @Parameter";
}
}
}
}
return new FileContentResult(byte_image, "image/jpeg");
}
At line else
how to do second select with reader?