I need to make a query in a table where the data is of type varbinary(max)
, so I 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'm reading line the query line, but how do I add the value to list_foto
?