Solved

Using COleCurrency with ODBC and Visual C++

Posted on 2004-03-26
4
410 Views
Last Modified: 2013-11-20
Hi,

I am writing a database application (using access).  I have data fields in the database that are defined as currency.  I have defined edit boxes within my applications as COleCurrency.  I am having problems using
rfx...

From research on the web it seems that the correct call is rfx_byte()...  (it's not rfx_currecny as that is only for DAO, as far as I can tell)

however, I get the following error when I use that:

rror C2664: 'RFX_Byte' : cannot convert parameter 3 from 'class COleCurrency' to 'unsigned char &'
        A reference that is not to 'const' cannot be bound to a non-lvalue

line of code looks like:

      RFX_Byte(pFX, _T("[CRDAmount]"), m_CRDAmount);

where m_CRDAmount is of the COleCurrency type.

So how do I fix this?

Nasa
0
Comment
Question by:nasa
[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
  • 2
4 Comments
 
LVL 1

Expert Comment

by:GJanusz
ID: 10689121
That error is pretty common, and I sure have seen it my share of times.  I don't have time to look up/test my answer right now, so I'll just quickly point out that RFX_Byte doesn't have a chance of working unless m_CRDAmount is 1 byte long (which it isn't).  The other thing is that the parameter types to the RFX_ functions are very indicative of what variable types they will work with.  (RFX_Byte takes a BYTE&.)
0
 
LVL 1

Author Comment

by:nasa
ID: 10690796
ok,

follow all that -- just wish I knew the best way to fix it....


Nasa
0
 
LVL 1

Accepted Solution

by:
GJanusz earned 125 total points
ID: 10691498
My sample code is at my previous employer, so all I can do now is point the way.  You will be well served by digging into RFX_ a bit.  If there was a neat RFX_ trick, it would only take 2 minutes to get the answer to your problem (and someone may yet have one for you!, but I don't).  However, if you have the time and inclination, you'll plan better for the future by writing your own RFX_ function and use it in your DoFieldExchange().

It appears that some of the hard work for such a custom-built RFX_ function can done by utilizing CFieldExchange::Default().  Look up what RFX_Double() does and how it uses Default().

Another place to start in MSDN is http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_record_field_exchange.3a_.how_rfx_works.asp
(i.e., all the RFX_ documentation).
0
 
LVL 1

Author Comment

by:nasa
ID: 10705507
Ok,

That's enough to scare me off....  I will just use long's (it just money) and handle the coversions/display myself.  Thanks for the info


Nasa
0

Featured Post

Technology Partners: 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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Suggested Courses

732 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