Hello !
I want to use ADO in a shared dynamic library. So, I create some methods to open and close a connection. Here is the code of these methods:
and here is the program which uses these methods :
The connection and the disconnection are OK but I have a "unHandled exception" after the execution of the program ( ie after the instruction 'return 2'). My platform is a WindowsNT one.
Is is possible to avoid it ?
Thanks for reply
Matthieu, a french programmer
I want to use ADO in a shared dynamic library. So, I create some methods to open and close a connection. Here is the code of these methods:
Code:
_RecordsetPtr RS_seat;
_ConnectionPtr CN_seat;
_CommandPtr CM_seat;
CCustomRs champBD;
IADORecordBinding *piAdoRecordBinding ;
MYDCLSPEC short _stdcall connecterBD()
{
HRESULT hr = NOERROR;
piAdoRecordBinding = NULL;
CString strConnection;
CString strCmdText;
strConnection = _T("Provider=MSDAORA.1;Password=seat;User ID=seat;Data
Source=seatecole;Persist Security Info=True");
strCmdText = _T("select * from tbl_cible");
RS_seat = NULL;
::CoInitialize(NULL);
try
{
CN_seat.CreateInstance(__uuidof( Connection ) );
CN_seat->Open( (LPCSTR)strConnection,"","",adConnectUnspecified);
}
catch (_com_error )
{ return 1;
}
return 0;
}
MYDCLSPEC short _stdcall deconnecterBD()
{
try
{
CN_seat->Close();
}
catch ( _com_error )
{
return 1;
}
return 0;
}
Code:
#include <malloc.h>
#include "d:\Recup\mumuzdll\ProgrammesInitiationC\test\test.h"
#include "d:\Recup\manipOracleC\dllBD\dllBD.h"
int main(int argc, char* argv[])
{ // Connection
if ( (resultat = connecterBD(&CN_seat)) == 1) {
printf("Bweurk!\n");
return 0;
}
else
{
// Déconnection
if ( (resultat = deconnecterBD(&CN_seat)) == 1 ) {
printf("Bouh!!");
return 0;
}
}
return 2;
}
The connection and the disconnection are OK but I have a "unHandled exception" after the execution of the program ( ie after the instruction 'return 2'). My platform is a WindowsNT one.
Is is possible to avoid it ?
Thanks for reply
Matthieu, a french programmer