473,395 Members | 2,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Help with Image in C#

3
Hi,

I am looking for a way to insert a jpeg image into a mysql database,retrive it and then display it in a form using C#. Could someone please help me?
Thanks
Sep 8 '07 #1
4 1043
Using System.io;
//insert image into the database

string strFn = "";
strFn = this.openFileDialog.FileName;
pictureBox.Image = Image.FromFile(strFn);
FileInfo fiImage = new FileInfo(strFn);

imageLength = fiImage.Length;
FileStream fs = new FileStream(strFn, FileMode.Open,
FileAccess.Read, FileShare.Read);
picture = new byte[Convert.ToInt32(this.imageLength)];
fs.Read(picture, 0, Convert.ToInt32(this.imageLength));
fs.Close();


to view the image

//tha variable picture is used to transfer the data from database into byte
//the datatype of variable picture is byte
MemoryStream ms = new MemoryStream(picture);
Sep 11 '07 #2
Using System.io;
//insert image into the database

string strFn = "";
strFn = this.openFileDialog.FileName;
pictureBox.Image = Image.FromFile(strFn);
FileInfo fiImage = new FileInfo(strFn);

imageLength = fiImage.Length;
FileStream fs = new FileStream(strFn, FileMode.Open,
FileAccess.Read, FileShare.Read);
picture = new byte[Convert.ToInt32(this.imageLength)];
fs.Read(picture, 0, Convert.ToInt32(this.imageLength));
fs.Close();


to view the image

//tha variable picture is used to transfer the data from database into byte
//the datatype of variable picture is byte
MemoryStream ms = new MemoryStream(picture);
pictureBox.Image = Image.FromStream(ms);
Sep 11 '07 #3
mzmishra
390 Expert 256MB
For storing image files ,you need to convert it to byte codes
Sep 11 '07 #4
Craigm
3
Thanks guys that worked well
Sep 12 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: zengou | last post by:
My application have many picturebox objects,when run it ,sometimes i will have a strange error,how to work out ,help me please!(in windows98,the error cause frequently than in windowsxp) ...
22
by: KitKat | last post by:
I need to get this to go to each folders: Cam 1, Cam 2, Cam 4, Cam 6, Cam 7, and Cam 8. Well it does that but it also needs to change the file name to the same folder where the file is being...
23
by: casper christensen | last post by:
Hi I run a directory, where programs are listed based on the number of clicks they have recieved. The program with most clicks are placed on top and so on. Now I would like people to be apple to...
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
2
by: tonsi | last post by:
I have a page but it wont center the div. Can anyone take a look at it and help. When I try to center in the body using text-align: center; it doesn't work with the main container (called Table_01)....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.