Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
Hello, I have saved some images in ms access database and i want to retrieve those images in Image field in front end. I have saved images in "OLE Object" format. Whenever i"m trying to retrieve those images it gives me an error "The file 'C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\130064593738380337' already exists.". Please solve my problem. Thanks....
 
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        cn.Open();
        OleDbCommand cm = new OleDbCommand("select * from ImageCollection where img_id='"+DropDownList1.SelectedItem.ToString()+"'",cn);
        OleDbDataAdapter da = new OleDbDataAdapter(cm);
        OleDbDataReader dr = cm.ExecuteReader();
        try
        {
            if (dr.Read())
            {
 
                string image1 = Convert.ToString(DateTime.Now.ToFileTime());
                string image2 = Convert.ToString(DateTime.Now.ToFileTime());
                FileStream fs1 = new FileStream(image1, FileMode.CreateNew, FileAccess.Write);
                FileStream fs2 = new FileStream(image2, FileMode.CreateNew, FileAccess.Write);
                byte[] bimage1 = (byte[])dr["passport_photo"];
                byte[] bimage2 = (byte[])dr["sign_photo"];
                fs1.Write(bimage1, 0, bimage1.Length - 1);
                fs2.Write(bimage2, 0, bimage2.Length - 1);
                fs1.Flush();
                fs2.Flush();
                Image1.ImageUrl = Convert.ToString(fs1);
                Image2.ImageUrl = Convert.ToString(fs2);
            }
            dr.Close();
            cn.Close();
        }
        catch (Exception ex)
        {
            throw ex;
        }
Posted 27-Feb-13 7:28am
Comments
richcb at 27-Feb-13 12:31pm
   
You are trying to write a file that already exists. Delete the existing files and then run it again. If it works this time then you will know that you have to change how you are writing the file. Maybe you could change the FileMode.CreateNew to FileMode.Append or .Open so that it just writes over or adds to the file that is already there.
Chiklu.Soumya at 27-Feb-13 13:08pm
   
It shows error when i wrote FileMode.Open.The error is "Could not find file 'C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\130064619000881758'."
When I wrote FileMode.Append it shows error "The process cannot access the file 'C:\Program Files\Common Files\Microsoft Shared\DevServer\10.0\130064617880809532' because it is being used by another process.
"
richcb at 27-Feb-13 13:43pm
   
Ok, how about adding an incrementer to the file path arguement of the filestream so that each time it creates one it has a slightly different file name? Let me ask you this, where is the "image1" and "image2" variables values coming from?
Chiklu.Soumya at 27-Feb-13 13:46pm
   
values of image1 and image2 comes from ImageCollection table.
richcb at 27-Feb-13 13:57pm
   
Ok, well I am not real sure what to do now. Hopefully someone will come along and give you a better suggestion. Sorry I could not help you.
Chiklu.Soumya at 27-Feb-13 14:05pm
   
It's ok.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Retrieve ms access data with the aid of recovery for access download
 
Post [spam link removed] contains of many helpful solutions for restoring ms access databases
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.150224.1 | Last Updated 14 Jun 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100