
May 28th, 2002, 11:17 AM
|
|
Contributing User
|
|
Join Date: Dec 2002
Posts: 14,575
  
Time spent in forums: < 1 sec
Reputation Power: 22
|
|
|
How to save images in an Access DB?
<i><b>Originally posted by : Ken Awamura (info@kencwb.com)</b></i><br />Hi, <br /><br />I´m trying to save an image to an Access Database using C#.<br /><br />1. The Db Table called 'Images' has the following fields : Id,Name,Data,ConType<br /><br />2. In order to get the atributes from the image file I´m using :<br /><br />//Get the file name from the upLoad textField<br />System.Web.HttpFileCollection colFiles = System.Web.HttpContext.Current.Request.Files; <br />System.Web.HttpPostedFile objCurrentFile = colFiles.Get(0); <br />System.String imgName = System.IO.Path.GetFileName(objCurrentFile.FileName );<br />//imgName will be something like : myImg.gif<br /><br />//Get the other attributes here<br />Stream imgStream = UploadFile.PostedFile.InputStream;<br />int imgLen = UploadFile.PostedFile.ContentLength;<br />byte[] imgBin = new byte[imgLen];<br /> int n = imgStream.Read(imgBin,0,imgLen);<br />string imgConType = UploadFile.PostedFile.ContentType;<br /><br /><br />Well, once I have all the attributes I need to save them in my Access Db.<br />I guess the ADO.NET part comes here, any ideas? <br /><br />Thanks, Ken<br />info@kencwb.com<br />
|