F
F
Fiasco2014-02-01 12:08:49
C++ / C#
Fiasco, 2014-02-01 12:08:49

How to insert an image into an OLE database field using C#?

Good day everyone!
There is an access database in mdb format, you need to insert a jpg image from an application developed in visual C# 2010.
In the database, pictures are stored in the field of the OLE object.
The fact is that if you add pictures directly through access, then the pictures will be stored in the OLE field as a Bitmap Image. These pictures are opened from access by double clicking the mouse.
There is the following code:

OdbcConnection Connection = new OdbcConnection();
...
sql = "INSERT INTO Фильм (Плакат) VALUES (" ' " + Image.FromFile(textBox8.Text) + " ' ");";
//в текстбоксе хранится путь до картинки
OdbcCommand Command = new OdbcCommand(sql, Connection);
Command.ExecuteNonQuery();

The code works, but in access the picture is entered in the form of binary data and it can no longer be opened through access.
Can you please tell me how to make C# save an image in the OLE field as a Bitmap Image?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question