Monday, March 12, 2012

MFC CDatabase and ODBC version

Hi all,

I created a CDatabase object, called OpenEx and checked the ODBC version with:

unsigned int version;

SQLGetEnvAttr(AfxGetHENV(),SQL_ATTR_ODBC_VERSION,&version,0,0);

and the version is 2. I want to make it 3 and I tried:

SQLSetEnvAttr(AfxGetHENV(),SQL_ATTR_ODBC_VERSION,(void*)SQL_OV_ODBC3,0);

It fails and I suppose it is because OpenEx already have an HDBC created. Does that mean I cannot use CDatabase and I have to write my own ODBC wrapper class? Thanks.

Kevin

You might be able to derive your own class from CDatabase and override AllocConnect adding the call to SQLSetEnvAttr.

No comments:

Post a Comment