I stored image from a folder to mysql database.image column type mediumblob..
but I cant come back to gridview image control inside templatefield
I am seeing icon but image not comess...
I think binary store and binary convert to image again problem..
WHAT İS THE WRONG?
image insert code
string fileName = fileuploadImage.PostedFile.FileName;
int fileLength = fileuploadImage.PostedFile.ContentLength;
byte[] imageBytes = new byte[fileLength];
fileuploadImage.PostedFile.InputStream.Read(imageBytes, 0, fileLength);
MySqlConnection conn1 = new MySqlConnection(baglan.connStr1);
conn1.Open();
string sql = "INSERT INTO kayit(ogrno,resim) VALUES" +
"('" + fileName + "'" +
",'" + imageBytes + "')";
MySqlCommand cmd = new MySqlCommand(sql, conn1);
int count=cmd.ExecuteNonQuery();
conn1.Close();
image comeback code
this is gridview source
<asp:TemplateField HeaderText="resim">
<ItemTemplate>
<asp:Image ID="Image1" runat="server" ImageUrl='<%# "xxx.ashx?ImID="+ Eval("id") %>' Height="150px" Width="150px"/>
</ItemTemplate>
</asp:TemplateField>
string imageid = context.Request.QueryString["ImID"];
MySqlConnection connection = new MySqlConnection(baglan.connStr1);
connection.Open();
MySqlCommand command = new MySqlCommand("select resim from kayit where id=" + imageid, connection);
byte[] buf = (byte[])command.ExecuteScalar();
context.Response.Clear();
context.Response.OutputStream.Write(buf, 0, buf.Length);
context.Response.ContentType = "image/jpeg";
context.Response.BinaryWrite(buf);
connection.Close();
context.Response.End();
this is code