Solved

unresolved external symbol CdbLastOLEError::GetDescription() VC8

Posted on 2007-03-22
3
984 Views
Last Modified: 2013-11-20
I am migrating from VC6 to VC2005. I can not seem to resolve this linker error in VS2005. It is generated by the GetDescription() object associated with CdbLastOLEError. Code segment and linker error shown below. I'm linking with VC8 versions ddao35d.lib (debug) and ddao35.lib (release). Compiler is set with these flags:

Unsigned Char - Yes (/J)
Treat wchar_t as built-in (/Zc:wchar_t-)

Does anyone know how to resolve this error?
Thanks!
---------------------------------------------------------
.
.
.
catch ( CdbException e )
{

CString strMsg;
CdbLastOLEError exError;

strMsg = exError.GetDescription(); // generates linker error

// Displays error number and description
TRACE( _T("\t CdbLastOLEError.Description: %d - %s\n"),
DBERR(e.m_hr), (LPCTSTR)strMsg);

strMsg.Empty();
}

Linker error
dbthread.obj : error LNK2001: unresolved external symbol "public: class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > __thiscall CdbLastOLEError::GetDescription(void)" (?GetDescription@CdbLastOLEError@@QAE?AV?$CStringT@DV?$StrTraitMFC_DLL@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@XZ)
0
Comment
Question by:VideoFletch
3 Comments
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 18771014
>>>> public: class ATL::CStringT<char,class

The char indicates that you are not using UNICODE strings. As far as I know, ATL *only*  can be called with UNICODE strings. If your MFC CStrings were single-byte strings you need to convert to UNICODE strings before calling ATL. Or you try to set the _UNICODE and UNICODE macro in your preprocessor settings, pray, and rebuild all ....

Regards, Alex
0
 
LVL 11

Accepted Solution

by:
alexcohn earned 500 total points
ID: 18771220
first of all - congrats: you're in a good company, see http://www.thescripts.com/forum/thread263470.html

http://msdn2.microsoft.com/en-us/library/ttc6chk1(VS.80).aspx says:
As of Visual C++ .NET, the Visual C++ environment and wizards no longer support DAO (although the DAO classes are included and you can still use them). Microsoft recommends that you use OLE DB Templates or ODBC for new projects. You should only use DAO in maintaining existing applications.

The DAO MFC libraries, including ddao35d.lib, are part of PlatformSDK and are not compatible with the new MFC. You are expected to #include <afxdao.h> and it will link daouuid.lib.
0
 

Author Comment

by:VideoFletch
ID: 18771784
Thanks!  I should have signed up sooner.  I've spent a week trying to resolve this issue through MSDN and other sites.  Took less than two hours from the experts!

Adding the <afxdao.h> and daouuid.lib was the trick.  PLUS:  changing the declaration of CdbLastOLEError   TO   CDaoErrorInfo.   The CdbLastOLEError is still in <dbdao.h>, but apparently no longer in the ddao35.lib.   Changing to CDaoErrorInfo and linking with the addition of daouuid.lib has corrected the linker error.

New Code looks like this:
-----------------------------------------------
catch ( CdbException e )
{
CString strMsg;
CDaoErrorInfo exError;
strMsg = exError.m_strDescription;    //note change from function call to member

// Displays error number and description
TRACE( _T("\t CDaoErrorInfo.Description: %d - %s\n"),
DBERR(e.m_hr), (LPCTSTR)strMsg);

strMsg.Empty();
}

0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

706 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now