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



The information in this article applies to:

  • Microsoft OLE DB Provider for ODBC 1.0
  • Microsoft OLE DB Provider for ODBC 2.0
  • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
  • Microsoft Visual C++, 32-bit Professional Edition 6.0
  • Microsoft Visual C++, 32-bit Learning Edition 6.0

This article was previously published under Q238296

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 that are discussed in this article are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, regarding the performance or reliability of these products.

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 in the following list to view the article in the Microsoft Knowledge Base:

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

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

60782 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.

Modification Type:MajorLast Reviewed:12/5/2003
Keywords:kbDatabase kbDTL kbMDACNoSweep kbOracle kbprb kbProvider kbtemplate KB238296