文章 "如何从 MQL5 (MQL4) 访问 MySQL 数据库" - 页 17

 

It's very useful.

But there is a problem when i insert chinese word  into mysql use cmd like this "INSERT INTO table (name,value) VALUES ('买订单','卖订单');",it return  an  error description"Query is empty."

How to solve this problem.

Thanks. 

 

同事们,请复制实际发布的版本、

我个人需要 MQL5 x64 的构建版,但使用主题中的链接无法下载 - 404

 
Khrisna Gunanasurya:

你好,为什么会收到这条信息?

连接失败!错误:Can't connect to MySQL server on 'mysql.hostinger.co.id' (10061)<~~~ 之前是 10060,我不知道为什么会变成这个。

谁能帮我解决这个问题?我已经试着上网搜索了,但还是碰壁。

谢谢

你好,Khrisna,你解决了这个错误吗?
 

您好、

我有一个问题。我想在 MySQL 表中记录交易,但总是收到查询为空的错误信息。

当我打印错误和查询时,它就在那里:

错误 #1065:查询为空;3

查询:INSERT INTO algo_trades (date, time, curr, ticket, error, trade, lot, entry, sl, tp, spread) VALUES ('2017-9-1',' 14:3:58','GBPUSD',8705334,0,'Sell',2,1.29892,1.29961,1.29812,0.9)

什么地方出错了?我在另一个代码中以同样的方式使用了这个库,运行完全正常。

非常感谢 Eugeniy 的分享。

 
cikahun:

您好、

我有一个问题。我想在 MySQL 表中记录交易,但总是收到查询为空的错误信息。

当我打印错误和查询时,它就在那里:

错误 #1065:查询为空;3

查询:INSERT INTO algo_trades (date, time, curr, ticket, error, trade, lot, entry, sl, tp, spread) VALUES ('2017-9-1','14:3:58','GBPUSD',8705334,0,'Sell',2,1.29892,1.29961,1.29812,0.9)

什么地方出错了?我在另一个代码中以同样的方式使用了这个库,运行完全正常。

非常感谢 Eugeniy 的分享。

使用 Google 可能更快

http://www.joellipman.com/articles/sql/error-1065-query-was-empty.html

SQL
  • 2012.12.13
  • Joel Lipman
  • www.joellipman.com
Posted on Dec 13, 12 at 01:12 PM What? In view of the fact that this error pops up in so many systems I take over, I have often gone down the wrong path following the red herring as it were when in fact the answer to this is very common. Why? Bespoke systems are the usual suspects. Developers will have told the system what to do when...
 

你好,阿兰、

非常感谢!我知道问题出在哪里了。

在我的情况下,经纪人给我的货币符号带有英镑符号。我已经删除了它,现在可以正常使用了。

再次感谢。

 

I used the attechtment dll to run EA, but it did not work and the log showed

"Cannot load 'C:\Users\ccb\AppData\Roaming\MetaQuotes\Tester\67381DD86A2959850232C0BA725E5966\Agent-127.0.0.1-3000\MQL5\libraries\MQLMySQL.dll' [193]
 Cannot call 'cMySqlVersion', '..\libraries\MQLMySQL.dll' is not loaded
 unresolved import function call"

Im using the mt5 x64

and here is my code:


#include <MQLMySQL.mqh>
//--- input parameters
string INI;
string Host, User, Password, Database, Socket; // database credentials
int Port,ClientFlag;
int DB; // database identifier
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   Print (MySqlVersion());
   INI = TerminalInfoString(TERMINAL_PATH)+"\\MQL5\\Scripts\\MyConnection.ini";
 // reading database credentials from INI file
 Host = ReadIni(INI, "MYSQL", "Host");
 User = ReadIni(INI, "MYSQL", "User");
 Password = ReadIni(INI, "MYSQL", "Password");
 Database = ReadIni(INI, "MYSQL", "Database");
 Port     = (int)StringToInteger(ReadIni(INI, "MYSQL", "Port"));
 Socket   = ReadIni(INI, "MYSQL", "Socket");
 ClientFlag = CLIENT_MULTI_STATEMENTS; //(int)StringToInteger(ReadIni(INI, "MYSQL", "ClientFlag")); 

 Print ("Host: ",Host, ", User: ", User, ", Database: ",Database);
 
 // open database connection
 Print ("Connecting...");
 
 DB = MySqlConnect(Host, User, Password, Database, Port, Socket, ClientFlag);
 
 if (DB == -1)
   Print ("Connection failed!Error: "+MySqlErrorDescription);
 else Print ("Connected!DBID#",DB);
 return 1;
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

   MySqlDisconnect(DB);
 
     
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
  
  }
//+------------------------------------------------------------------+

the X64 version dll file can not be loaded.

 
我正在使用多插入查询, 但它不起作用,但当我使用单插入时,它就起作用了,查询如下

Query = Query + "INSERT INTO `history` (an, oi, oc) VALUES (" + (string) AccountNumber() + ", " + (string) OrderTicket() + ", '" + (string) OrderComment() + "');";


我做错了什么?

 
Eugeniy Lugovoy:

嗯...如果我没记错的话,在最新版本中(张贴在讨论区中)我有相关规则:)

好吧,UTF 问题仍然存在。如果不是工作过度,我会在本周至周末尝试解决这个问题。

下午好,尤金。

非常感谢你提供的这个库,我正在我的项目 中积极使用它。

请问你是否成功解决了 UTF 的问题?如何下载当前版本?

我需要 MQL4 x32-x64 版本。再次感谢。)

 
can you help me to change charset to UTF-8,thank you very much