From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Saving a binary file to a database with the Database Connectivity Toolset

Code and Documents

Attachment

Download All

Overview


These programs will allow you to save and retreive a binary file into a database. This is useful for things such as jpeg's or xls files.

Introduction

SQL databases can store many datatypes, but there are also many files that need to be saved as a binary that can only be read with an appropriate program. For example .xls files can be opened only with programs like Microsoft Excel, or OpenOffice.org, but not a text editor. These VIs implement a LabVIEW solution using the Database Connectivity Toolset to save these types of files and read them back from the database and open them in the associated program.

Database support

The datatype we are going to take advantage of is the BLOB. There are different BLOB datatypes that can accomodate different size files. A blob is a collection of binary data. Blobs are typically images, audio or other multimedia objects, though you can also store binary code a blob. Database support for blobs is not universal. So depending on your database you might not be able to implement this code.

The Microsoft ODBC driver for Oracle and the Microsoft OLE DB Provider for Oracle DO NOT support BLOB (binary) data types. You will not be able to use Oracle with the Database Connectivity Toolset for binary data with these drivers. The workaround is to use the OLE DB Provider (and ODBC driver) provided by Oracle from their web site at: http://technet/oracle.com/tech/nt/ole_db/.

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors