1
I need to perform a query, in a table, where the data is of the type varbinary(max), then created the method below:
public List<byte[]> preenche_fotos(string nCrm)
    {
        consql.bd_string();
        SqlConnection sqlconn = new SqlConnection(consql.sqlconn);
        List<byte[]> list_foto = new List<byte[]>();
        try
        {
            consql._sql = @"SELECT bfoto
                            FROM crm_fotos
                            WHERE ncrm = @nCrm";
            SqlCommand cmd = new SqlCommand(consql._sql, sqlconn);
            cmd.Parameters.Add("@nCrm", SqlDbType.VarChar).Value = nCrm;
            sqlconn.Open();
            SqlDataReader leitor = cmd.ExecuteReader();
            while (leitor.Read())
            {
                list_foto.Add(???????);
            }
        }
        catch (Exception error)
        {
            MessageBox.Show("Error" + error);
        }
        finally
        {
            sqlconn.Close();
        }
        return list_foto;
    } 
}
So with the method Read of DataReader, I’ll read the query line by line, but how do I add the value to the list_foto?
The solution worked out?
– novic
Perfect friend, thank you very much.
– Thomas Erich Pimentel