LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DBGetColBinary -- num of bytes copied?

Hello,

 

How do we know the num of bytes really copied by DBGetColBinaryBuffer or by DBGetColBinary?

 

The only diff between them is that DBGetColBinary also allocated mem.

 

Thanks,

0 Kudos
Message 1 of 5
(3,448 Views)

Hi ER111,

 

After reading through the documentation it appears that DBGetColBinary will return 1 byte only, and if you are wanting to get different sizes to read you will use the DBGetColBinaryBuffer the bufferLength parameter is how many bytes it will read

 

http://www.ni.com/pdf/manuals/370502a.pdf

 

Regards,

James W.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 5
(3,419 Views)

Hi James,

Thanks,

I'm asked about "num of bytes really copied" and your answer talk about "will read".

I posted this q after see that no any mention about it issue in the docs. Look strange.

 

Please let me explain.

Lets say that the record is about 237,000 bytes.

 

In C# I get the size before read, then allocate mem, and then read to that mem:  

 

long len = reader.GetBytes(1, 0, null, 0, 0);

                        // Create a buffer to hold the bytes, and then 

                        // read the bytes from the DataTableReader.

                        Byte[] buffer = new Byte[len];

                        reader.GetBytes(1, 0, buffer, 0, (int)len);

 

http://msdn.microsoft.com/en-us/library/system.data.datatablereader.getbytes.aspx

 

 

This is very important when you work with large amount of data like BLOB.

The main purpose is to store multimedia files like images and sounds and the CVI docs talked about several values in the records.

 

The issue is for both these two funcs:

  With DBGetColBinaryBuffer need to allocate area big enough before call it.

  With DBGetColBinary do not need to allocate area before call it. Better for unknown sizes.

But still, they both not return the size of bytes copied to the buffer.

 

So, how can we work with that data?

 

Generally each func that allocate mem to a pointer must return also the size so the programmer could work with that mem.

Thanks,

0 Kudos
Message 3 of 5
(3,408 Views)

Hi ER111,


I apologize for the missunderstanding. Looking through the documentation, the function it looks like you actually will want to use to get simialr functionality to .NET would b:

 

DBGetColumnAttribute (, 1, ATTR_DB_COLUMN_ACTUAL_SIZE, );

 

Looking at the example from the documentation, it provides a similar call pattern to what you described

 

resCode = DBGetColumnAttribute (hstmt, i, ATTR_DB_COLUMN_NAME,

&tempStr);

DBFree(tempStr);

resCode = DBGetColumnAttribute (hstmt, i, ATTR_DB_COLUMN_VALUE,

&valueVariant);

resCode = CA_VariantConvertToType (&valueVariant,

CAVT_CSTRING, &tempStr);

CA_FreeMemory(tempStr);

 

Regards,



James W.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 5
(3,373 Views)

James Hello,

 

This is exactly what I asked for.

 

Now you sharp and specific, I looked for just the following line in my code:

    DBGetColumnAttribute (hstmt, 1, ATTR_DB_COLUMN_ACTUAL_SIZE, &size);

 

Thank you very much for your important support.

0 Kudos
Message 5 of 5
(3,366 Views)