Hi,
I am to retrieve one picture file from an Access table, using these
Server Error in '/App18_devst' Application.
Buffer cannot be null.
Parameter name: buffer
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Buffer cannot be null.
Parameter name: buffer
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentNullException: Buffer cannot be null.
Parameter name: buffer]
System.IO.MemoryStream..ctor(Byte[] buffer, Boolean writable) +14257217
App18._Default.refresh_img() +438
App18._Default.BindData() +442
App18._Default.refresh_pg() +10636
App18._Default.Page_Load(Object sender, EventArgs e) +724
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18408
I am to retrieve one picture file from an Access table, using these
OleDbCommand cmd = new OleDbCommand("SELECT [photo_file] FROM [ite_tab3] where [ite_id]=@par_id", conn); if (tb_iteabbr.Text!="") { cmd.Parameters.Add("@par_id", OleDbType.VarChar).Value = lb_iteid.Text.Trim(); } else { cmd.Parameters.Add("@par_id", OleDbType.VarChar).Value = ""; } byte[] bArray = (byte[])cmd.ExecuteScalar(); MemoryStream fs = new MemoryStream(bArray); System.Drawing.Image img = new System.Drawing.Bitmap(fs); using (FileStream fw = new FileStream(Path.Combine(Server.MapPath("~/"), "output" + Session["counter"].ToString() + ".jpg"), FileMode.Create)) { fw.Write(bArray, 0, bArray.Length); } fs.Flush(); fs.Close(); ...but I get this exception error. how to adjust the above codes?
Server Error in '/App18_devst' Application.
Buffer cannot be null.
Parameter name: buffer
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Buffer cannot be null.
Parameter name: buffer
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentNullException: Buffer cannot be null.
Parameter name: buffer]
System.IO.MemoryStream..ctor(Byte[] buffer, Boolean writable) +14257217
App18._Default.refresh_img() +438
App18._Default.BindData() +442
App18._Default.refresh_pg() +10636
App18._Default.Page_Load(Object sender, EventArgs e) +724
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18408
Many Thanks & Best Regards, Hua Min