I am trying to read image ( binary data type) directly from database. I can read if the image is single ,but if there are multiple images put together( inside one column) , I am not be able to read it. I am getting an error when try to debug: System.ArgumentOutOfRangeException was unhandled by user code Message="Index and count must refer to a location within the buffer.\r\nParameter name: bytes" Source="mscorlib" ParamName="bytes" StackTrace: at System.Text.ASCIIEncoding.GetString(Byte[] bytes, Int32 byteIndex, Int32 byteCount) at GetImage.Page_Load(Object sender, EventArgs e) in c:\Documents and Settings\jc\My Documents\Visual Studio 2005\WebSites\CashApp\Cash\GetImage.aspx.cs:line 50 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) Can you take a look at below code and let me know what I am doing wrong? there are columns called FrontImageOffset, FrontImageSize that tells me where an image's byte stream ends and a new image begins so, I am using a sql command like below to figure out what I am supposed to looking for.. sql = "select FrontImageOffset, FrontImageSize from CDData where TransactionId=" + TransactionId; using (SqlCommand cmd = new SqlCommand(sql, cn)) Below is code that I am using it.using
using
public
{
TransactionId = (
TransactionId =
sql =
cn.Open();
dr.Read();
imageBytes = (
}
imageBytes, oleTypeStart, oleTypeLength);
tempStream =
imageBytes, oleOffset, imageBytes.Length - oleOffset);
imageBytes, 0, imageBytes.Length);
bmp =
Response.ContentType =
bmp.Save(Response.OutputStream,
Response.End();
imgBytes.CopyTo(
imgList.Add(newimage);
dr.Close();
bigImage.AddRange((
tempStream.Position = 0;
System.Drawing.