Hi,
I developed a code in C++ to connect to MYSQL using ADODB.
I am using pConnection->BeginTrans() before doing any insert/delete/update operation.
pConnection is _ConnectionPtr. Complete code is given below
After the successful operation I am doing pConnection->CommitTrans(), incase of failure I am calling pConnection->RollbackTrans() to revert those operation.
I am able to connect to MySQL database and also able to perform some insert/update/delete operation.
But in case of MYSQL replication scenario, it is not working. Insert/update/delete operation is failing. If I remove the pConnection->BeginTrans(), then it is working fine.
The probelm is BeginTrans(). Could anyone guide me how to proceed with BeginTrans() function? or Do I need to modify any settings in .ini?
kindly provide solution for this issue.
Thanks,
Vinoth
<Code>
#import "C:\Program Files (x86)\Common Files\System\ado\msado60.tlb" rename("EOF", "adoEOF") //modified for TFS defect-737814
#import "C:\Program Files (x86)\Common Files\System\ADO\msadox.dll"
using namespace ADODB;
using namespace ADOX;
int _tmain(int argc, _TCHAR* argv[])
{
::CoInitialize(NULL);
_ConnectionPtr pConnection = NULL;
_CommandPtr pCmdChange = NULL;
bstr_t strCnn = L"Driver={MySQL ODBC 5.2w Driver};Server=localhost;Database=test;User=root;Password=****;Option=8;charset=utf8;no_ssps = 1";
//bstr_t strSQLChange = L"INSERT INTO \`newtable\` (\`IntVal\`, \`FloatVal\`, \`StringVal\`) VALUES (12, 12.3, \'Hello\')";
bstr_t strSQLChange = L"INSERT INTO `newtable` (`IntVal`, `FloatVal`, `StringVal`) VALUES (12, 12.3, 'Hello')";
HRESULT hRes = pConnection.CreateInstance(__uuidof(Connection));
pConnection->Open (strCnn, "", "", adConnectUnspecified);
VARIANT varValue;
::VariantInit(&varValue);
_RecordsetPtr ptrRec;
pConnection->BeginTrans();
//ptrRec = pConnection->Execute(strSQLChange, &varValue, adCmdText|adExecuteNoRecords/*, &ptrRec*/);
HRESULT hr = pConnection->raw_Execute(strSQLChange.copy(false), &varValue, adCmdText|adExecuteNoRecords, &ptrRec);
pConnection->CommitTrans();
//pConnection->RollbackTrans();
pConnection->Close();
pConnection.Release();
::CoUninitialize();
return 0;
}
<Code>
I developed a code in C++ to connect to MYSQL using ADODB.
I am using pConnection->BeginTrans() before doing any insert/delete/update operation.
pConnection is _ConnectionPtr. Complete code is given below
After the successful operation I am doing pConnection->CommitTrans(), incase of failure I am calling pConnection->RollbackTrans() to revert those operation.
I am able to connect to MySQL database and also able to perform some insert/update/delete operation.
But in case of MYSQL replication scenario, it is not working. Insert/update/delete operation is failing. If I remove the pConnection->BeginTrans(), then it is working fine.
The probelm is BeginTrans(). Could anyone guide me how to proceed with BeginTrans() function? or Do I need to modify any settings in .ini?
kindly provide solution for this issue.
Thanks,
Vinoth
<Code>
#import "C:\Program Files (x86)\Common Files\System\ado\msado60.tlb" rename("EOF", "adoEOF") //modified for TFS defect-737814
#import "C:\Program Files (x86)\Common Files\System\ADO\msadox.dll"
using namespace ADODB;
using namespace ADOX;
int _tmain(int argc, _TCHAR* argv[])
{
::CoInitialize(NULL);
_ConnectionPtr pConnection = NULL;
_CommandPtr pCmdChange = NULL;
bstr_t strCnn = L"Driver={MySQL ODBC 5.2w Driver};Server=localhost;Database=test;User=root;Password=****;Option=8;charset=utf8;no_ssps = 1";
//bstr_t strSQLChange = L"INSERT INTO \`newtable\` (\`IntVal\`, \`FloatVal\`, \`StringVal\`) VALUES (12, 12.3, \'Hello\')";
bstr_t strSQLChange = L"INSERT INTO `newtable` (`IntVal`, `FloatVal`, `StringVal`) VALUES (12, 12.3, 'Hello')";
HRESULT hRes = pConnection.CreateInstance(__uuidof(Connection));
pConnection->Open (strCnn, "", "", adConnectUnspecified);
VARIANT varValue;
::VariantInit(&varValue);
_RecordsetPtr ptrRec;
pConnection->BeginTrans();
//ptrRec = pConnection->Execute(strSQLChange, &varValue, adCmdText|adExecuteNoRecords/*, &ptrRec*/);
HRESULT hr = pConnection->raw_Execute(strSQLChange.copy(false), &varValue, adCmdText|adExecuteNoRecords, &ptrRec);
pConnection->CommitTrans();
//pConnection->RollbackTrans();
pConnection->Close();
pConnection.Release();
::CoUninitialize();
return 0;
}
<Code>