PRB: Access Violation in SQORA32.dll when Using ODBC OLE DB Provider

ID: Q238296


The information in this article applies to:
  • Microsoft OLE DB Provider for ODBC, versions 1.0, 2.0
  • Microsoft Visual C++, 32-bit Editions, version 6.0


SYMPTOMS

When passing a parameter in a SQL statement in an Oracle NT database using Oracle's ODBC driver version 8.00.50 and the Microsoft OLE DB Provider for ODBC, an access violation occurs in SQORA32.dll.

Here is an example of the SQL String that might cause a problem:


Insert into table1 values(?) 
The problem only occurs when specifying a length part (DBPART_LENGTH) for the accessor.

The third-party products discussed in this article are manufactured by vendors independent of Microsoft; we make no warranty, implied or otherwise, regarding these products' performance or reliability.


CAUSE

The OLE DB Provider for ODBC performs the following sequence of ODBC calls:

  • SQLSetStmtAttr with SQL_ATTR_PARAM_BIND_OFFSET.


  • SQLBindParameter passing null for the octet length.


  • SQLDescField with SQL_DESC_OCTECT_LENGTH_PTR.


Oracle's ODBC driver should be adding the values specified by the SQL_ATTR_PARAM_BIND_OFFSET and SQL_DESC_OCTECT_LENGTH_PTR. Instead, Oracle ignores the value in SQL_ATTR_PARAM_BIND_OFFSET. This causes an invalid address to be calculated.


RESOLUTION

Please contact Oracle Corporation for more information on obtaining a fixed version of Oracle's ODBC driver.
For information about how to contact Oracle Corporation, click the appropriate article number below to view the article in the Microsoft Knowledge Base:

Q65416 Hardware and Software Third-Party Vendor Contact List, A-K

Q60781 Hardware and Software Third-Party Vendor Contact List, L-P

Q60782 Hardware and Software Third-Party Vendor Contact List, Q-Z


STATUS

This behavior is by design.


MORE INFORMATION

Steps to Reproduce the Problem

  1. Create a table with a char(50) field.


  2. Run the ATL OLE DB Consumer Wizard in Visual C++ to create an accessor class for the table.


  3. Modify the class so that it uses a parameter map rather than a column map such as:
    
    class CInsertTestAccessor
    {
    	public:
    		TCHAR m_szField1[51];
    		ULONG m_lLength;
    
    		BEGIN_PARAM_MAP(CInsertTestAccessor)
    			SET_PARAM_TYPE(DBPARAMIO_INPUT)
                            COLUMN_ENTRY_LENGTH(1, m_szField1, m_lLength)
    		END_PARAM_MAP()
    }; 


  4. Add the following code to insert a value into the table using an INSERT INTO command with a parameter:
    
    	// open a connection using the connection string
    	CDataSource ds;
    	hr = ds.OpenFromInitializationString(T2W(m_strConnection));
    	
    	CSession sn;
    	sn.Open(ds);
    
    	CCommand<CAccessor<CInsertTestAccessor> > cmd;
    
    	TCHAR szSQLInsert[200];
    	szSQLInsert[0]='\0';
    	_tcscat(szSQLInsert, _T("Insert into "));
    	_tcscat(szSQLInsert, _T(m_strTableName));
    	_tcscat(szSQLInsert, _T(" VALUES (?)"));
    
    	//insert the record
    	_tcscpy(cmd.m_szField1, _T("string"));
    	cmd.m_lLength = strlen(cmd.m_szField1);
    
    
    	// Set properties for open
    	LPCTSTR szCommand = NULL;
    	hr = cmd.CreateCommand(sn);
    	CComPtr<ICommandText> spCommandText;
    	hr = cmd.m_spCommand->QueryInterface(&spCommandText);
    	if (SUCCEEDED(hr))
    	hr = spCommandText->SetCommandText(DBGUID_SQL, T2COLE(szSQLInsert));
    
    	cmd.Open(sn, szSQLInsert);
    	cmd.Close();
     


The variables m_strConnection and m_strTableName in the code earlier are CStrings. You can replace these with your own strings that represent the connection string and table name respectively.

Additional query words:

Keywords : kbtemplate kbATL kbDatabase kbDTL kbODBC kbOLEDB kbVC600 kbGrpVCDB
Version : WINDOWS:1.0,2.0; winnt:6.0
Platform : WINDOWS winnt
Issue type : kbprb


Last Reviewed: December 8, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.