SQLDriverConnect fails to connect when using MFC function CreateFile

Hello,

I'm trying to convert an application that would use the function fopen_s to open an xml file that is read into our system to use the MFC function CreateFile.

We use Visual Studio 2010 Premium and have a C++ code baseline.

After opening the existing file it is read in and we keep the handle to the file open so that other users or processes can't modify the file so it is locked.

We have a sql function call that fails:

AFX_SQL_SYNC(::SQLDriverConnect( m_hdbc, hWnd, reinterpret_cast<SQLTCHAR *>(pszConnectInput),

                        SQL_NTS, reinterpret_cast<SQLTCHAR *>(szConnectionOutput),

                        $nResult, wConnectOption));

The function call above works when I switch back to the previous implementation that uses fopen_s.

I am wondering why this is occurring and how do I fix it.

The error is : Unhandled exception at 0x00000000 in process.exe: 0xC0000005: Access violation location 0x00000000000000000.

Thanks,

Jeff





August 26th, 2015 7:58pm

Hi Jeff,

As the issue is more related to C++ programming, I recommend you post the question in the Visual C++ forum. It is appropriate and more experts will assist you.

Additionally, there are a similar thread and blog about the above error for your reference.
Access violation reading location 0x00000000. 'new' keyword
Why does Software Crash #1 The Access Violation

Thanks,
Lydia Zhang

Free Windows Admin Tool Kit Click here and download it now
August 27th, 2015 11:21pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics