This problem also occurs in Visual Studio 2010 if a hotfix that is newer than hotfix 2607393 is installed.
This problem also occurs in Visual Studio 2008 if a hotfix that is newer than hotfix 2607389 is installed.
Modify your codeModify your code to guard against the empty-string condition. To do this, create a class that is derived from CDatabase, and use this class as the database class in your application.
In this derived class, override the OpenEx method. In the override, first call the CDatabase version of OpenEx to make sure that the connection string is obtained from the call to SQLDriverConnect. Then, decrypt and store the connection string in a CString object that you can reference later.
Migrate to Visual Studio 2013Use a more recent version of MFC. For example, use the version that is included in Visual Studio 2013.
In Visual Studio 2013, the GetConnect() method returns a CString. When the method is called, the encrypted connection string is decrypted and returned to the caller, who is then responsible for zeroing out the memory for security.
Article ID: 2915724 - Last Review: 6 Dec 2013 - Revision: 1