I have an ASP.NET website where I want to enter EmployeeName , and upload EmployeePhoto, then retrieve Employee Info and display Employeephoto on website.
I have created an SQL table with EmployeePhoto - type "image".
I use this code to insert photo on (it works fine) http://i.stack.imgur.com/qmphk.png
However when I want to load my inserted photo in SQL into website, I get this Inputstream does not exist error.
load photo codes & error http://i.stack.imgur.com/X2okW.png
I don't want to use the httphandler solution
EDIT: I have no correct answer yet :(
Thank you very much.
cnn.Open();
SqlCommand cmd = new SqlCommand("SELECT EmployeeFirstName,EmployeeLastName,EmployeePhoto FROM Employees WHERE EmployeeID = @myvalue", cnn);
cmd.Parameters.AddWithValue("@myvalue", (ListBox1.SelectedValue));
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
TextBox1.Text = dr.GetString(0);
TextBox2.Text = dr.GetString(1);
byte[] imagedata = (byte[])dr[2];
InputStream.Read(imagedata, 0, (byte[])dr[2]);
Image Image1 = Image.FromStream(imagedata);
}
}
cnn.Close();