08-11-2013 06:55 AM
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,
08-12-2013 03:45 PM
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,
08-13-2013 01:29 AM
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,
08-14-2013 08:42 AM
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,
08-14-2013 09:16 AM
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.