MySQL Forums
Forum List  »  Connector/C++

MYSQL replication: ADO Programming in C++
Posted by: Vinoth Kumar S
Date: February 25, 2015 10:28PM


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.



#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[])
_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;

_RecordsetPtr ptrRec;


//ptrRec = pConnection->Execute(strSQLChange, &varValue, adCmdText|adExecuteNoRecords/*, &ptrRec*/);

HRESULT hr = pConnection->raw_Execute(strSQLChange.copy(false), &varValue, adCmdText|adExecuteNoRecords, &ptrRec);






return 0;


Options: ReplyQuote

Written By
MYSQL replication: ADO Programming in C++
February 25, 2015 10:28PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.