CREATE TABLE Logo( id int, image varbinary(max), status char(1) ) INSERT INTO Logo(id,status, image) SELECT '1', 'Y', * FROM OPENROWSET(BULK N'E:\logo.jpg', SINGLE_BLOB) image; select image from Logo where id=1 and status='Y'
protected void Page_Load(object sender, EventArgs e) { string constr = ConfigurationManager.ConnectionStrings["conn"].ToString(); SqlConnection con = new SqlConnection(constr); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = CommandType.Text; cmd.CommandText = "select image from Logo where id=1 and status='Y'"; SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); Response.BinaryWrite((Byte[])dr[0]); con.Close(); Response.End(); }
<table > <tr> <td><asp:Image ID="logo" runat="server"/></td> </tr> </table >
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)