Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using following code to retrieve an image from a folder to my application in a picture box.
C#
private DevExpress.XtraEditors.Controls.PictureMenu GetMenu(DevExpress.XtraEditors.PictureEdit edit)
        {
            PropertyInfo pi = typeof(DevExpress.XtraEditors.PictureEdit).GetProperty("Menu", BindingFlags.NonPublic | BindingFlags.Instance);
            if (pi != null)
                return pi.GetValue(edit, null) as DevExpress.XtraEditors.Controls.PictureMenu;
            return null;
        }
        private void InvokeMenuMethod(DevExpress.XtraEditors.Controls.PictureMenu menu, String name)
        {
            MethodInfo mi = typeof(DevExpress.XtraEditors.Controls.PictureMenu).GetMethod(name, BindingFlags.NonPublic | BindingFlags.Instance);
            if (mi != null && menu != null)
                mi.Invoke(menu, new object[] { menu, new EventArgs() });
        }
        private void simpleButton1_Click_1(object sender, EventArgs e)
        {
            //the name can be on of the following values: OnClickedLoad;OnClickedSave;OnClickedCut;OnClickedCopy;OnClickedPaste;OnClickedDelete
            InvokeMenuMethod(GetMenu(pictureEdit1), "OnClickedLoad");
        }

I want to store this in my Database using datatype BLOB. How could I do this?
Can this image be stored in DB as BLOB or I should convert it as byte?
Posted
Updated 7-Sep-10 20:14pm
v2
Comments
Sandeep Mewara 8-Sep-10 2:15am    
Use PRE tags to format code part of your question or answer. It makes them readable.
Abhishek Sur 13-Sep-10 16:32pm    
I think byte[] is capable of storing the images very easily. I have been using byte[] for several times and did not find any problem.

No u hav eto convert into Binaryformat.Blob is used for storing large datafiles in Database.
 
Share this answer
 
Actually, there is an easier way. Since SQL Server 2005,BLOBS are discouraged. You now have VARCHAR(MAX) which can store character data up to 2 GB. If you want to store images, place it on a richtextbox. Get the formatted text by:
String image_binary = richTextBox1.Rtf;


This will translate the image into a richtextformat - a format that stores images in text. You could now place the image_binary like any other String and retrieve it. It could now be placed on another richTextBox.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900