Solved

How to Store and retrieve BMP's and JPG's into database recordset

Posted on 1998-09-01
4
728 Views
Last Modified: 2008-02-01
We need to store some large binary data into database . It may be of bitmap or jPEG or text file.
How to store them in database. I think we can make use of " CLongBinary" and corresponding RFX_LongBinary for CRecordset classes .
We are not able to store data and retrieve data from table.
Can anybody suggest the way of reading and writing bitmap file from database , using CLongBinary and RFX_LongBinary or any other way how ro deal witrh BLOB.
The database may be any type Oracle or MSAccess etc. It should be database indipendent.
0
Comment
Question by:rsquek
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

by:rsquek
ID: 1171821
Adjusted points to 200
0
 
LVL 2

Expert Comment

by:duneram
ID: 1171822
blobs are definitely the way to go. I'll look into it
0
 
LVL 2

Accepted Solution

by:
milenvk earned 200 total points
ID: 1171823
Well, here's the deal. You better use CByteArray and RFX_Binary, since they don't have boundary limit like CLongBinary and RFX_LongBinary. The way to go is:

// theByteArray is the array that is binded to the BLOB using RFX_Binary
// theImageByteSize is the size of the file in bytes
theByteArray.SetSize(theImageByteSize)
BYTE* pb = theByteArray.GetData();
// pbTheImageDataFromFile is the memory where you copied the data from the file
memcpy(pb, pbTheImageDataFromFile, theImageByteSize);
// rs is your recordset - you have to have called AddNew or Edit before that
rs.Update();

That's the way to put the data in the DB...
To get the data (assuming the recordset has positioned its cursor to the record of interest):

BYTE *pb = theByteArray.GetData();
int size = theByteArray.GetSize();

// Now *pb points to the memory with the data from the picture file
// and size is the size of the picture file
0
 
LVL 2

Expert Comment

by:milenvk
ID: 1171824
Opps... I forgot the binding...
Here is the recordset's DoFieldExchange() part:

void CMyRecordset::DoFieldExchange( CFieldExchange* pFX )
{
  //...
  RFX_Binary(pFX, "TheColumnName", theByteArray);
  //...
}

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question