problem with CDataSource throving exception
Hello!
Here is the whole method called DBInitCommandTemplate below that cause the
DS.Open to throw an exception after this method has been called several
times.
Sometimes it's after 10 times or more and sometimes it's less then 10 times.
As I have written in many previous mail I have only one statement in the try
block and that is the DS.Open so as far
as I understand it's only code within this DS.Open that can cause the catch
handler to be called.
I have made a minor change in the code when calling the DS.Open and that is
I use literal value directly as parameter when calling the DS.Open is this
way
hr = DS.Open("OraOLEDB.Oracle", "IDTHU1", "CCR_DTH_USER", "P55534552");
When I run a test in the morning I managed do call this
CAlterObj::DBInitCommandTemplate 21 times before
I run into exception being throws by DS.Open.
If I use catch ( CException* ex ) insted of catch (...)
I get the following compile error
C:\project\IDTH\DTHToolObjects\AlterObj.cpp(3626) : error C2061: syntax
error : identifier 'CException'
C:\project\IDTH\DTHToolObjects\AlterObj.cpp(3626) : error C2310: catch
handlers must specify one type
C:\project\IDTH\DTHToolObjects\AlterObj.cpp(3631) : error C2317: 'try' block
starting on line '3619' has no catch handlers
Can anybody suggest anything to come closer a solution to my problem.
//Here is the complete code I use
//***************************
HRESULT CAlterObj::DBInitCommandTemplate(BSTR Provider,BSTR DataSource,BSTR
UserId,
BSTR Password, BSTR ProductID,BSTR Revision,
BSTR ApplicationID, BSTR ApplicationRev,
BSTR SubfileID)
{
TRACE_FUNCTION_IN(_T("CAlterObj::DBInitCommandTemplate"));
HRESULT hr S_OK;
CCommand<CAccessor<CSetRole> > sqlRole;
CSession Session;
CDataSource DS;
CDBPropSet dbInit(DBPROPSET_DBINIT);
CDBPropSet dbPropSet(ORAPROPSET_COMMANDS);
CString strTemp;
LPSTR lpProduct = NULL;
LPSTR lpProductRev = NULL;
LPSTR lpApplicationID = NULL;
LPSTR lpApplicationRev = NULL;
LPSTR lpSubFileID = NULL;
LPSTR lpTempBuff = NULL;
//Convert string values
::RealocateMemAndSetValue(&lpProduct,ProductID);
::RealocateMemAndSetValue(&lpProductRev,Revision);
::RealocateMemAndSetValue(&lpApplicationID,ApplicationID);
::RealocateMemAndSetValue(&lpApplicationRev,ApplicationRev);
::RealocateMemAndSetValue(&lpSubFileID,SubfileID);
m_lpSubFileKey = ::CombineStr(lpProduct,"|",lpProductRev,"|");
lpTempBuff = ::CombineStr(m_lpSubFileKey,lpApplicationID,"|");
FREE(&m_lpSubFileKey);
m_lpSubFileKey = lpTempBuff;
lpTempBuff = NULL;
lpTempBuff = ::CombineStr(m_lpSubFileKey,lpApplicationRev,"|",lpSubFileID);
FREE(&m_lpSubFileKey);
m_lpSubFileKey = lpTempBuff;
lpTempBuff = NULL;
dbInit.AddProperty(DBPROP_AUTH_USERID, UserId);
dbInit.AddProperty(DBPROP_AUTH_PASSWORD, Password);
dbInit.AddProperty(DBPROP_INIT_DATASOURCE, DataSource);
dbInit.AddProperty(DBPROP_INIT_LCID, (long)1053);
dbInit.AddProperty(DBPROP_INIT_PROMPT, (short)4);
dbInit.AddProperty(DBPROP_INIT_PROVIDERSTRING, OLESTR(""));
strTemp = Provider;
//hr = DS.Open(strTemp, &dbInit);
try
{
TRACER_STREAM(_T("CAlterObj::DBInitCommandTemplate Before
DS.Open\r\n"));
/////hr = DS.Open("OraOLEDB.Oracle", &dbInit);
hr = DS.Open("OraOLEDB.Oracle", "IDTHU1", "CCR_DTH_USER",
"P55534552");
TRACER_STREAM(_T("CAlterObj::DBInitCommandTemplate After
DS.Open\r\n"));
}
catch (...)
{
TRACER_STREAM(_T("CAlterObj::DBInitCommandTemplate Exception on
Open\r\n"));
}
TRACER_STREAM(_T("CAlterObj::DBInitCommandTemplate Before
Session.Open\r\n"));
hr = Session.Open(DS);
if ( !SUCCEEDED(hr) ) {}
//Set role
hr = sqlRole.Open(Session);
if ( !SUCCEEDED(hr) ) {}
hr = LoadProcedureRules(&Session,&dbPropSet,ProductID, Revision,
SubfileID);
//[1] Fetch all commands. Create a CLoadSeqMembers
// and fill the derived list with CloadSeqMember
hr = LoadCommands(&Session,&dbPropSet,ProductID,
Revision,ApplicationID,ApplicationRev,SubfileID);
//[2] Now we have all commands. Fill evry CLoadSeqMember CParTmpls with
// CParTmpl. If CParTmpl is of type PTYPE_VALUE Or PTYPE_SYNTAX Or
// PTYPE_SYNTAXDIGSTR fill CParTmpl with ValueRanges
if(hr == S_OK)
hr = LoadValueRanges(&Session,&dbPropSet,ProductID,
Revision,ApplicationID,ApplicationRev,SubfileID);
//[3] Now, get the SyntaxBranches and Valueranges for syntax and
syntaxbranch params
// Fill CParTmpl with CSubParams. Fill CSubParams with CValueRanges
if(hr == S_OK)
hr = LoadSyntaxBranch(&Session,&dbPropSet,ProductID,
Revision,ApplicationID,ApplicationRev,SubfileID);
//[4] Now Get the parameters for each structures.
// Fill CMemberformat with CParamNode's
if(hr == S_OK)
hr = LoadCmdStructures(&Session,&dbPropSet,ProductID,
Revision,ApplicationID,ApplicationRev,SubfileID);
//[5] Now get the parameterconnections for each structure
// Fill and connect CMemberFormat to its connections and fill evry
parameter
// with its connections
if(hr == S_OK)
hr = LoadParamStructures(&Session,&dbPropSet,ProductID,
Revision,ApplicationID,ApplicationRev,SubfileID);
//[6] Now we load general rules this should be done in VB in the Future.
This rules applies
// To all subfiles and not to a specific subfile
if(hr == S_OK)
hr = LoadGeneralRules(&Session,&dbPropSet);
//Detta anrop ska l?ggas med senare, n?r vi l?gger till kontrollen f?r
//"CheckOptionalMandatoryRules".
if(hr == S_OK)
hr = LoadOptionalMandatoryRules(&Session,&dbPropSet,ProductID, Revision);
Session.Close();
DS.Close();
//FREE ALL Libraries
//::CoFreeUnusedLibraries(); now we are doing this in alter destruktor
//FREE ALL USED VARIABLES
::FREE(&lpProduct);
::FREE(&lpProductRev);
::FREE(&lpApplicationID);
::FREE(&lpApplicationRev);
::FREE(&lpSubFileID);
::FREE(&lpTempBuff);
return hr;
}
//Tony