LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save image as binary data in database: LabVIEW adds 4 bytes

Our LabVIEW application has to save  jpeg-images into a MS-SQL database as binary data.

 

We use the database connectivity toolkit (LV8.5).

The image can not saved direcly using SQL, a stored procedure hat to be used. One of the parameter is "@data" with datatype "binary". In Principle eeverythiong works but: We open the jpeg-file as binary (string) and use that data to send to the database.

 

BUT: 

No we've seen, that LabVIEW (the db-toolkit) adds 4 characters at the beginning of the binary data.
LabVIEW can remove this 4 character when we read the file, but: other applications (non LabVIEW) do not know about this 4 leading characters --> corrupt data.

 

How can we save the binary "string" /image data directly without LabVIEW is changing the data when writing it into the db? 

 

Due the access with other applications we have to write directly the binary data (no LabVIEW-Cluster, Array, etc.) 

 

0 Kudos
Message 1 of 14
(8,431 Views)

Hi zav,

it sounds like you first write this file as binary data. If you do it, then connect a false constant to the top right input. LabVIEW can store some additional information to the file, which you in this case don´t need.

 If not, which functions do you use??

 

Hope it helps.

Mike

Message 2 of 14
(8,429 Views)

Zav,

 

i haven't saved any images as binary data in databases yet, so i cannot tell you if this is the reason for the four byts you are seeing.

But if you save an array in a binary file, LV adds 4 bytes in the beginning in order to store the size of the array. I think that this is done in your database as well....

For the files, you can disable this prepending with a boolean parameter at the "write to binary file". I don't know if this is available in the database connectivity toolkit...

 

hope this helps,

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 3 of 14
(8,426 Views)

The 4 characters are added by the toolkit (C:\Program Files\National Instruments\LabVIEW 8.5\vi.lib\addons\database\Command.llb\Cmd Set Parameter Value (C).vi), see attachement. I do not want to modify the toolkit...

 

 

We directly binary-read from a given jpg-file (without touching the data) and connect the (binary-)string-output to the input of toolkit-vi: "Cmd Set Parameter Value.vi".

 

How can we directly write binary data without having the modification in the binary data?

 

 

Message Edited by zav on 09-03-2008 09:06 AM
Message Edited by zav on 09-03-2008 09:13 AM
Message Edited by zav on 09-03-2008 09:14 AM
Download All
0 Kudos
Message 4 of 14
(8,422 Views)
You can use DB Tools Execute Query VI to run your own SQL query, in which you can add the binary data you read from the file.

___________________
Try to take over the world!
Message 5 of 14
(8,411 Views)
Direct SQL queries (Insert, Update, etc.) are not allowed on the database we use for security reasons - we only can execute stored procedures (ok, we can customize them using the "DB Tools Execute Query VI") , but the LabVIEW-DB-Toolkit should allow - in our example - store unmodified binary data that other applications can access it.
0 Kudos
Message 6 of 14
(8,359 Views)

zav wrote:

but the LabVIEW-DB-Toolkit should allow - in our example - store unmodified binary data that other applications can access it.

You might wish to visit the Product Suggestion Center.

 

I assume that you have version 1.0.1 of the DB toolkit which is several years old, but NI released a new version with 8.6. I have no idea if it includes this functionality or not, but even if not, you can create it by writing code which will be parallel to the toolkit. Maybe not the best solution, but it works.


___________________
Try to take over the world!
Message 7 of 14
(8,346 Views)

Any updates on this problem?

 

I'm running into the same situation (using DB toolkit for LV8.6) and am wondering whether anyone has any other ideas?

0 Kudos
Message 8 of 14
(8,081 Views)

I have a different problem. I also use stored procedures and I cannot upload binary files larger than 8 kilobyte which is a bit small for PNG images and waveforms 😕

 

I am using labview 8.6.1 and teststand 4.2

0 Kudos
Message 9 of 14
(7,327 Views)

 

 

I am having the same problem.

 

Please see image attached. This code works well to save the binary file to sql(database toolkit not shown here)  but I can't read the binary file in Crystal reports.

 

I have a VB.NET   program that saves binary into sql and crystal reports reads it no problem.

 

 

Has anyone reach a solution on this?

 

Thanks

JCollado
0 Kudos
Message 10 of 14
(6,766 Views)