Some of my friends requested me to make a tutorial about the Oracle database and C#. This time, I’d like to share about how to Save Image or Picture from C# Object into Oracle BLOB Type. It’s very easy if you know the trick.
To make the tutorial simple, let’s assume a table with 1 field. It’ll be used to store a collection of photos.
Next, open or create a new C# project.
Oracle.ManagedDataAccess NuGet package to your project.
Somewhere in one of your C# classes, create a function to read an image as an array of bytes. Use the following code to achieve that. This array of bytes will be used as the BLOB value in Oracle Database.
Finally, use the following code to insert an image into Oracle Database.
It’s done simply by creating a database connection and doing insert command as usual.
The difference is, you need to define the insert value parameter as
That’s all I can write today. Hope this tutorial can be useful and solve your problem. Thanks for reading.