Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

C# .NET WinForms MySQL - saving image file

Posted on 2008-06-10
1
Medium Priority
?
3,315 Views
Last Modified: 2013-11-07
I need to save an image file into MySql database table, using C# .NET 3.0 WinForms
I hold the actual image in variable "img" (which is type of Image).
The database column type is longblob.
What code can I use to insert such an image into that table?
0
Comment
Question by:eugene-g
1 Comment
 
LVL 53

Accepted Solution

by:
Dhaest earned 150 total points
ID: 21759344
First, consider that loading images (and files in general) into a database is probably bad regarding the performance. If at all, you should store them in a separate database...

Besides that, you need to read about the .AppendChunk and .GetChunk to write/read to IMAGE (and TEXT) fields in SQL Server.
Another way to do this is store the file location in the database and simply place image files on the hard drive.  As far as removing the file just remove the record holding the location and then use the kill statement to delete the file off the hard drive.


Handling BLOB Data With Connector/NET
http://dev.mysql.com/doc/refman/5.0/en/connector-net-using-blob.html
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question