?
Solved

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

Posted on 1998-09-01
4
Medium Priority
?
746 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 400 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

718 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