Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » How to read a Blob from a SQLite3 DB (I can write a blob with a string but i can't read it )
How to read a Blob from a SQLite3 DB [message #43970] Tue, 02 December 2014 05:03 Go to next message
lmsp is currently offline  lmsp
Messages: 2
Registered: December 2014
Junior Member
I have the next code to write a BLOB in a SQLite3 DB:

My .sch file:

TABLE_(BLOBS_TABLE)
INT_ (NUMBER)
BLOB_ (DATA)
END_TABLE

And C++ write(I omit the code of creation an open the DB):

S_BLOBS_TABLE row;

row.NUMBER = 1;
row.DATA = String(blob.GetBuffer(), blob.GetBufferLength());

SQL * Insert(FILES_BLOBS_TABLE)(row);

The class blob.GetBuffer() returns a char* and blob.GetBufferLength() the size of the buffer in bytes.

My problem comes when I try to read the data. I have tried:

SQL.Execute("select DATA from BLOBS_TABLE WHERE NUMBER=" +AsString(1) );

if(SQL.Fetch())
{
StringBuffer data( SQL[0] );
char* pBuffer = new char[data.GetLength()];
memcpy( pBuffer, data, data.GetLength() );
}

And:

SQL.Execute("select DATA from BLOBS_TABLE WHERE NUMBER=" +AsString(1) );

if(SQL.Fetch())
{
String data = SQL[0];
char* pBuffer = new char[data.GetLength()];
memcpy( pBuffer, (const char*)data, data.GetLength() );
}

But any solution doesn't work. Any help?


Re: How to read a Blob from a SQLite3 DB [message #43975 is a reply to message #43970] Thu, 04 December 2014 21:08 Go to previous messageGo to next message
BioBytes is currently offline  BioBytes
Messages: 307
Registered: October 2008
Location: France
Senior Member
Hi,

Did you check this:

http:// stackoverflow.com/questions/18801197/sqlite-c-put-and-retrie ve-blob Rolling Eyes

Biobytes
Re: How to read a Blob from a SQLite3 DB [message #43988 is a reply to message #43970] Sun, 07 December 2014 19:14 Go to previous message
lmsp is currently offline  lmsp
Messages: 2
Registered: December 2014
Junior Member
Thank you, Biobytes, for your response. I will follow the indications in the link you have posted.
Previous Topic: Firebird Database integration
Next Topic: Bugs with svn build 8144 and NOAPPSQL
Goto Forum:
  


Current Time: Fri Jun 21 22:18:35 CEST 2024

Total time taken to generate the page: 0.01736 seconds