New Posts New Posts RSS Feed: Upload Image
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Upload Image

 Post Reply Post Reply
Author
bala View Drop Down
Groupie
Groupie
Avatar

Joined: 18-Aug-2010
Location: Brazil
Posts: 54
Post Options Post Options   Quote bala Quote  Post ReplyReply Direct Link To This Post Topic: Upload Image
    Posted: 23-Aug-2010 at 6:07am
Hi Vinod

I did not undestand object mapper..

How you binding also not undestanding..
If possible can you pass code or step.

ImageUpload CurrentFile = bsFile.Current as ImageUpload;

This line making really terrible for me..

Thanks
Back to Top
vinothvdp View Drop Down
Newbie
Newbie
Avatar

Joined: 21-Sep-2007
Location: India
Posts: 27
Post Options Post Options   Quote vinothvdp Quote  Post ReplyReply Direct Link To This Post Posted: 23-Aug-2010 at 5:43am
Hi Bala,

No, i am not using any third party tools.

"ImageUpload"  is name of the table which included into ideablade object mapper with the same name.

using bellow step i am getting current item of the binding source, 

ImageUpload CurrentFile = bsFile.Current as ImageUpload;

And update the property of image column

CurrentFile.File= content;

Regards,
Vintoh
Back to Top
bala View Drop Down
Groupie
Groupie
Avatar

Joined: 18-Aug-2010
Location: Brazil
Posts: 54
Post Options Post Options   Quote bala Quote  Post ReplyReply Direct Link To This Post Posted: 23-Aug-2010 at 5:35am
Hi

Are you using webservice for it?

I am not able to understand

  ImageUpload CurrentFile = bsFile.Current as ImageUpload;

Could you able to put light on it

thanks
Back to Top
vinothvdp View Drop Down
Newbie
Newbie
Avatar

Joined: 21-Sep-2007
Location: India
Posts: 27
Post Options Post Options   Quote vinothvdp Quote  Post ReplyReply Direct Link To This Post Posted: 20-Aug-2010 at 10:33pm
Hi,

You can use below code to upload image to db using ideablade,

  OpenFileDialog openFileDialog1 = new OpenFileDialog();
        private void SelectFileultraButton_Click(object sender, EventArgs e)
        {
            openFileDialog1.Filter = "All Files (*.*)|*.*";
            openFileDialog1.Title = "Select File";
            if (DialogResult.Cancel == openFileDialog1.ShowDialog())
            {
                return;
            }
            fileNameUltraTextEditor.Text = openFileDialog1.FileName;
            string fileName = Path.GetFileName(fileNameUltraTextEditor.Text.ToString());
            byte[] content = ReadFileToByteArray(fileName);
            ImageUpload CurrentFile = bsFile.Current as ImageUpload;
            CurrentFile.File= content;
            CurrentFile.FileName = fileName;
        }
        protected static byte[] ReadFileToByteArray(string fileName)
        {
            FileStream fileStream = new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Read);
            long len;
            len = fileStream.Length;
            Byte[] fileAsByte = new Byte[len];
            fileStream.Read(fileAsByte, 0, fileAsByte.Length);
            MemoryStream memoryStream = new MemoryStream(fileAsByte);
            return memoryStream.ToArray();
        }

        private void saveToolStripButton_Click(object sender, EventArgs e)
        {
            if (PM.HasChanges())
            {
                try
                {
                    PM.SaveChanges();
                    MessageBox.Show("Sucessfully saved");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }
            else
            {
                MessageBox.Show("Nothing to save");
            }
        }


Regards,
Vinoth
Back to Top
ting View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 27-Mar-2009
Location: San Francisco
Posts: 427
Post Options Post Options   Quote ting Quote  Post ReplyReply Direct Link To This Post Posted: 20-Aug-2010 at 6:38pm
You can use a third party control that allows users to select an image, or you will have to implement functionality to browse the disk for the file.  Once you have the bits, you can assign the bits to the property of the entity and it will get saved to the database when you call SaveChanges().
Back to Top
bala View Drop Down
Groupie
Groupie
Avatar

Joined: 18-Aug-2010
Location: Brazil
Posts: 54
Post Options Post Options   Quote bala Quote  Post ReplyReply Direct Link To This Post Posted: 19-Aug-2010 at 12:49pm
Hi
I want to upload image using DevForce
How I can achevie this?
 
 
Thanks
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down