After more work I got it working in MQL4 (Sort of)
I have tarnsformed the code to MQL5
I am using code posted on the web that includes ANSITOUNICODE UNICODETOANSI.
ansiquery=UNICODE2ANSI(query2);
int length=StringLen(query2);
int res2 = mysql_real_query(mysql,ansiquery,length);
int res = mysql_store_result(mysql);
row = mysql_fetch_row(res); //Only pick up first occurrence.
row = ANSI2UNICODE(row);
Now "row" should be "MYSQL_ROW". Whatever that is
in MQL4 I can get correct results by stripping of the first 8 bytes on row declared as "string"
in MQL5 I get garbage at the end sometimes and sometimes correct results doing the same
I have tried to find out how the MYSQL_ROW is constructed but not found it
After more work I got it working in MQL4 (Sort of)
I have tarnsformed the code to MQL5
I am using code posted on the web that includes ANSITOUNICODE UNICODETOANSI.
ansiquery=UNICODE2ANSI(query2);
int length=StringLen(query2);
int res2 = mysql_real_query(mysql,ansiquery,length);
int res = mysql_store_result(mysql);
row = mysql_fetch_row(res); //Only pick up first occurrence.
row = ANSI2UNICODE(row);
Now "row" should be "MYSQL_ROW". Whatever that is
in MQL4 I can get correct results by stripping of the first 8 bytes on row declared as "string"
in MQL5 I get garbage at the end sometimes and sometimes correct results doing the same
I have tried to find out how the MYSQL_ROW is constructed but not found it
https://www.mql5.com/en/articles/69
cheers
- 2010.05.18
- Alexander
- www.mql5.com
investeo,
thanks, but how does that help me working with my MySQL database?
To add pain to injury.
I decided to try the function "mysql_result" that supposedly will give me the result directly. Tried both in MQL4 and MQL5
the mysql_result is defined in the 5.5 ref manual and I am using libmysql.dll from the 5.5 distribution. Neither MQL4 nor MQL5 can find
mysql_result in the libmysql.dll
Did you try EAX_Mysql script?
It available here https://www.mql5.com/en/code/855
With some code modification we can connect to MySQL database easily.
- votes: 10
- 2012.08.22
- Michael Schoen | English Russian Portuguese
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am struggling with retrieving data from MySQL. There are quite a few samples around both for MT4 and MT5. I have tried a few of them and they work.
But they all retrieve complete rows of data from MySQL. I want to retrieve single values with qualified SQL-statements. Something like "Select Level, Takeprofit from Table1 where TradeID equals zzzz"
Spent hours searching the web.