Hi,
I am have student_photo field which is an Image data type in SQL Server and I want to know how can I load the image in my application..
Here is what i am doing in my WinForm application:
public Image byteArrayToImage(byte[] byteArrayIn)
{
MemoryStream ms = new MemoryStream(byteArrayIn);
Image returnImage = Image.FromStream(ms);
return returnImage;
}
private void button1_Click(object sender, EventArgs e)
{
SqlConnection sql_connection = new SqlConnection(@"...");
sql_connection.Open();
SqlCommand sql_command = new SqlCommand("select student_photo from student", sql_connection);
SqlDataReader sql_reader = sql_command.ExecuteReader();
ObservableCollection<object> trends = new ObservableCollection<object>();
while (sql_reader.Read())
{
MyKidsData data1 = new MyKidsData()
{
student_photo = byteArrayToImage((byte[])sql_reader["student_photo"]),
};
pictureBox1.Image = data1.student_photo;
trends.Add(data1);
}
}
but in Xamarin Forms, I am getting this error:
'Image' does not contain a definition for 'FromStream'
on this line:
Image returnImage = Image.FromStream(ms);
Kindly help.....
Thanks,