I'm not much of a C++ expert. In the zip is the full tree of the "project" created in visual studio. In VS I just used the compile command to get the DLL. Please take from there...I'm afraid I can't give any pointers on other building methods or Make files.
OK thanks, I was confused by the project file extension - I'm using visual C++ 2008 express edition which uses .vcproj for it's project file extensions - but it can read the earlier version project file. Are you sure you posted your latest source file ? I found I had to add: row[i].len = strlen(row[i].string); after line #52 of mysql_wrapper.cpp (i.e. after row[i].string = lrow[i]; ) in order to get any data back from the database into my mq4 code.
I also found I had to comment out the calls to mysql_free_result() in MySQL_FetchRow() in mysql.mqh in order for the strings from the database query to still be available when control was returned to my mq4 code. Maybe it would be a good idea to change the local variable liResult to a global variable (say giResult) in mysql.mqh and have a seperate function (say MySQL_FreeResult()) to do the call to mysql_free_result() when the user has finished with the strings so that they persist for as long as the user requires them.
gc1:
OK thanks, I was confused by the project file extension - I'm using visual C++ 2008 express edition which uses .vcproj for it's project file extensions - but it can read the earlier version project file.
Are you sure you posted your latest source file ? I found I had to add:
row[i].len = strlen(row[i].string);
after line #52 of mysql_wrapper.cpp (i.e. after row[i].string = lrow[i]; )
in order to get any data back from the database into my mq4 code.
Thanks for the feedback! The code posted worked for me. On review kind a strange it did. 8-) I adjusted the code as suggested.
I have found a small problem. On my system if MySQL_FetchRow() is called with a SQL SELECT command that returns an empty set (i.e. no data matches the select clause) then this crashes the terminal. Including some code in MySQL_FetchRow() to call mysql_num_rows() and only call MT4_mysql_fetch_row() if there is 1 or more row(s) of data seems to fix this.
MySQL_FetchArray() crashes my terminal too.. I've no idea about why could it be, any ideas?
Edit: Solved it by taking the "lsResult" variable outside of the function and passing it as parameter. I pass newly created variable each time I need to fetch different number of fields (as terminal crashes on ArrayResize(lsResult, ..) if function was already called at least once and fetched another number of fields previously).
I'm not much of a C++ expert. In the zip is the full tree of the "project" created in visual studio. In VS I just used the compile command to get the DLL. Please take from there...I'm afraid I can't give any pointers on other building methods or Make files.
Russell
Russell
many many thanks. I have now the db working.
OK thanks, I was confused by the project file extension - I'm using visual C++ 2008 express edition which uses .vcproj for it's project file extensions - but it can read the earlier version project file. Are you sure you posted your latest source file ? I found I had to add: row[i].len = strlen(row[i].string); after line #52 of mysql_wrapper.cpp (i.e. after row[i].string = lrow[i]; ) in order to get any data back from the database into my mq4 code.
Thanks for the feedback! The code posted worked for me. On review kind a strange it did. 8-) I adjusted the code as suggested.
Thanks! Small update as suggested attached
Russell
MT4_mysql_fetch_row crashes the terminal in vista
string lsQuery = "SELECT * FROM `symbols`";
MySQL_FetchArray(lsQuery, lsSymolData);
crush
err=mysql_errno(giMySQL); if(err>0){Print(AccountServer()+ " Ошибка в getsymbol() функция MySQL_FetchArray() err # "+err+" "+mysql_error(giMySQL) );return(err);}
for (int i = 0; i < ArrayRange(lsSymolData,0); i++){
for (int j = 0; j < ArrayRange(lsSymolData,1); j++){
// Print(i+","+j+": "+lsSymolData[i][j]);
}
}
table symbols:
id symbols
1 EURUSD
2 GBPUSD
3 GBPJPY
please fix it..
MySQL_FetchArray() crashes my terminal too.. I've no idea about why could it be, any ideas?
Edit: Solved it by taking the "lsResult" variable outside of the function and passing it as parameter. I pass newly created variable each time I need to fetch different number of fields (as terminal crashes on ArrayResize(lsResult, ..) if function was already called at least once and fetched another number of fields previously).