OCL and ADO COM
Date: 6 Mar 2003 11:36:13 -0800
Message-ID: <65cd3805.0303061136.425c9002_at_posting.google.com>
[Quoted] I am attempting to write a dll external stored procedure that will extract data out of an oracle table and then write that data into a sql server table using. I used OCL to pull the data out. when I attempt to createinstace of a COM object in the dll it generates an access violation and crashes the database. I have to restart SQL Navigator.
The C code compiles to a dll without any problems. The system runs and will query oracle for all the information I request and execute the CoInitializeEx with an hr of success. However when the Createinstace is run attempting to generate a connection object, dr watson pops up with a the access violation problem.
code segments
#ifndef _WIN32_DCOM
#define _WIN32_DCOM
#endif
#import "C:\Program Files\Common Files\System\ado\msado15.dll"
no_namespace rename("EOF", "adoEOF" ) // Correct place to import ADO.
#include <Objbase.h>
#include "ocl.h"
#include "oci.h"
#include <stdio.h>
using namespace ocl;
int BridgeData(OraQuery& rsCnfgInfo, OraQuery& rsData, OraQuery&
rsConn)
{
int rtn = S_OK; char pszCols[500]; char pszColNm[] = "SRC_DATA_TBL_COL_NAME"; char sql[1000]; // initialize COM HRESULT hr = CoInitializeEx (NULL, COINIT_MULTITHREADED); if(FAILED(hr)) return E_FAIL; _ConnectionPtr pCnn; _RecordsetPtr pRs; // get the connection info from the rsConn recordset _bstr_t bstrCnnStr(rsConn.field("Connect_str").getString()); _bstr_t bstrCnnUsr(rsConn.field("DBMS_USER").getString()); _bstr_t bstrCnnPwd(rsConn.field("DBMS_PASS").getString()); // put all this garbage in a try catch block try{ // connect to the remote DBMS fails ==>> hr = pCnn.CreateInstance(__uuidof(Connection)); if(FAILED(hr)) _com_issue_error(hr);
// called using
OraQuery rsCnfgInfo(connection); OraQuery rsData(connection); OraQuery rsConn(connection); if(BridgeData(rsCnfgInfo, rsData, rsConn) == E_FAIL) return PTR_BRIDGE;
Thanks in advance,
Steven
sszelei_at_softprossoftware.com Received on Thu Mar 06 2003 - 20:36:13 CET