hi ,
i have problem with Retrieving image from DB
i have a table with image datatype
i store a file by using code as follows
--------------------------------------------------
string strType;
int intLength,intStatus;
Stream ipStream;
intLength = File1.PostedFile.ContentLength;
strType = File1.PostedFile.ContentType;
byte []imgContent = new byte[intLength];
ipStream = File1.PostedFile.InputStream;
intStatus = ipStream.Read(imgContent, 0, intLength);
SqlCommand cmd = new SqlCommand("sp_insert_image", connection);
cmd.Parameters.Add("@pname", SqlDbType.Image).Value = imgContent;
cmd.Parameters.Add("@type", SqlDbType.VarChar).Value = strType;
cmd.CommandType = CommandType.StoredProcedure;
connection.Open();
cmd.ExecuteNonQuery()
----------------------------------
it inserted into db.
but ,
while reading from db,table value in dataset like as follows
SqlDataAdapter da = new SqlDataAdapter("select pname,type from img_tab ",con);
DataSet ds = new DataSet();
da.Fill(ds);
pname
---------
System.Byte[] ---------> it doesnt retrieve binary value.
--------------------------------
problem 2
---------------
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
Response.ContentType = dr["type"].ToString();
Response.BinaryWrite(dr["pname"]); in this line error
}
Error 2 Argument '1': cannot convert from 'object' to 'byte[]' D:\velu\Image\readrealimage.aspx.cs 30 34 D:\velu\Image\
Error 1 The best overloaded method match for 'System.Web.HttpResponse.BinaryWrite(byte[])' has some invalid arguments D:\velu\Image\readrealimage.aspx.cs 30 13 D:\velu\Image\
so Help me to identify this