LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How I save a 1D-folat array to MS Sql Server"s image field?

How I save a 1D-folat array to MS Sql Server"s image field?

I try.

First all I flat the array.

Then I insert the flated string into the table.It 's OK.

I read it from the table.

There is a error.

The field data is empty.

why?

1.jpg2.jpg3.jpg4.jpg

0 Kudos
Message 1 of 8
(3,496 Views)

from your pictures

 

your array > string conversion is "big endian,network order" the conversion of the string back into the array is "little endian" - have you checked those? (they should be that same)

 

James

 

(edit1 - from the pictures you also never seem to be wiring the flattened array string into the database table so the data is never there to read back anyway!!!)

(edit 2 - you also are reading back an ID which is never inserted into the table so you are expecting the table to be dim1x4 when you write and dim1x5 when you read - you are reading the wrong index!!!)

CLD; LabVIEW since 8.0, Currently have LabVIEW 2015 SP1, 2018SP1 & 2020 installed
0 Kudos
Message 2 of 8
(3,476 Views)

In the upper part of your attached code, you never do anything with the flattened data (all you use is the error output). What is the point of the sequence structure?

0 Kudos
Message 3 of 8
(3,464 Views)

Image field for a array? Are you talking about blob type (...)?  It could be a simple varchar(max)...

 

Just use the Array to spreadsheet string and insert the array, then retrieve with Spreadsheet string to array. There's no need to flatten the data since it's not a binary type like an image.

0 Kudos
Message 4 of 8
(3,447 Views)

TimeWaveZero wrote:

Just use the Array to spreadsheet string and insert the array, then retrieve with Spreadsheet string to array. 


This is a lossy conversion that does not allow recovery of the identical DBL array due to limitations in the decimal formatting. Not the same! It is also significantly less efficient.

0 Kudos
Message 5 of 8
(3,442 Views)
@Altenbach

Oh yes, i've totally forgotten about the IEEE 754
Thanks.

@Thread

Blob type field should be stored as byte array, cause the SQL parser can interpret a little small set characters used by flatten to string as a delimiters (i.e ", ', *), then the insert *can* fail. Just cast the array to a variant or flatten into a cluster, and then wire it into Insert function. LabVIEW already handles the conversion.
0 Kudos
Message 6 of 8
(3,414 Views)

thanks you answer

I try it

change the sql server field type from image to varchar(max)

 but the data that read from server is empty.

0 Kudos
Message 7 of 8
(3,405 Views)

LabVIEW already have examples illustrating how to store arrays in BLOB Fields.

 

Look at the Database Logging (Parametrized).vi and the Playback.vi on the NI Example Finder.

Message 8 of 8
(3,385 Views)