Discussion of article "How to Access the MySQL Database from MQL5 (MQL4)" - page 10

 
my email: 178255721@qq.com
 
 
1982EAcsc :

Hello, it looks like MySQL deny connection for user ODBC on localhost.

You can try to check StackOverflow: http://stackoverflow.com/questions/23950722/how-to-overcome-error-1045-28000-access-denied-for-user- odbclocalhost-u ;

how to overcome ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO) permanently
how to overcome ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO) permanently
  • stackoverflow.com
when am trying to open mysql in windows cmd by typing mysql. the following error is occuring. And then by looking similar queries i somehow got a temporary solution by using and then typing the password, is working...
 

Hi Eugeniy Lugovoy.

I used MQLMySQL to implement the common query, insert, update, delete operations, but there is a problem, can not insert Chinese, query out of the Chinese is also garbled, I would like to ask, you middleware packaging process have set the encoding? I want to ask, you middleware packaging process has set the code? The phenomenon is as follows:

DROP TABLE IF EXISTS `tb_test_pat`;

CREATE TABLE `tb_test_pat` (

`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `symbol` varchitecture

`symbol` varchar(255) NOT NULL, `start_time` datetime, `tb_test_pat`; CREATE TABLE

`start_time` datetime NOT NULL,

`end_time` datetime NOT NULL, `trend` int(255)

`trend` int(10) NOT NULL, `points` int(10)

`points` int(10) unsigned zerofill NOT NULL, `comments` text CHARacteristic

`comments` text CHARACTER SET utf8,

PRIMARY KEY (`id`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Failed to insert Chinese

Error: Query was empty query: INSERT INTO tb_test_pat (trend, symbol, start_time, end_time, points, comments) VALUES (1, 'EURUSD ','2014.12.16 13:00 ','2014.12.17 20:00',8,'Test 12')

English Insertion Succeeded

Succeeded: INSERT INTO tb_test_pat (trend, symbol, start_time, end_time, points, comments) VALUES (1,'EURUSD','2014.12.16 13:00','2014.12.17 20 :00',8,'abc')


What's this for?

 
Jiayou Hu:

Hi Eugeniy Lugovoy.

I used MQLMySQL to implement the common query, insert, update, delete operations, but there is a problem, can not insert Chinese, query out of the Chinese is also garbled, I would like to ask, you middleware packaging process have set the encoding? I want to ask, you middleware packaging process has set the code? The phenomenon is as follows:

DROP TABLE IF EXISTS `tb_test_pat`;

CREATE TABLE `tb_test_pat` (

`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `symbol` varchitecture

`symbol` varchar(255) NOT NULL, `start_time` datetime, `tb_test_pat`; CREATE TABLE

`start_time` datetime NOT NULL,

`end_time` datetime NOT NULL, `trend` int(255)

`trend` int(10) NOT NULL, `points` int(10)

`points` int(10) unsigned zerofill NOT NULL, `comments` text CHARacteristic

`comments` text CHARACTER SET utf8,

PRIMARY KEY (`id`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Failed to insert Chinese

Error: Query was empty query: INSERT INTO tb_test_pat (trend, symbol, start_time, end_time, points, comments) VALUES (1,'EURUSD','2014.12.16 13:00 ','2014.12.17 20:00',8,'Test 12')

English Insertion Succeeded

Succeeded: INSERT INTO tb_test_pat (trend, symbol, start_time, end_time, points, comments) VALUES (1,'EURUSD','2014.12.16 13:00','2014.12.17 20 :00',8,'abc')


What's this for?

You can try to execute next command after MySQL connect.

SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'

Possible some of such settings is not set to UTF.

 

Another one solution to executenext commands one-by-one after connection.

SET NAMES 'utf8'

SET CHARACTER SET 'utf8'

SET SESSION collation_connection = 'utf8_general_ci'

 
Eugeniy Lugovoy:

Another one solution to executenext commands one-by-one after connection.

SET NAMES 'utf8'

SET CHARACTER SET 'utf8'

SET SESSION collation_connection = 'utf8_general_ci'

It still doesn't work, but I found the problem

bool __stdcall MySqlExecute( int pConnection, wchar_t* pQuery)

{

...

char Query[16384];

sprintf_s(Query, wcslen(pQuery)+10, "%S", pQuery); // When executing to this line, Chinese is encountered, and Query becomes an empty string resulting in an error message: Error: Query was empty query: UPDATE tb_test_pat SET comments_test_pat SET comments_test_pat SET comments_test_pat SET comments_test_pat SET comments_test_pat SET comments_test_pat test_pat SET comments='Chinese'

Can you help to fix this problem? Thank you very much! I'm 64 bit

 
Jiayou Hu:

It still doesn't work, but I found the problem

bool __stdcall MySqlExecute( int pConnection, wchar_t* pQuery)

{

...

char Query[16384];

sprintf_s(Query, wcslen(pQuery)+10, "%S", pQuery); // When executing to this line, Chinese was encountered, and Query became an empty string resulting in an error message: Error: Query was empty query: UPDATE tb_test_pat SET comments='Chinese'. test_pat SET comments='Chinese'

Can you help to fix this problem? Thank you very much! I'm 64 bit

Yes, "sprintf_s" and "sprintf's" do not support Chinese. I will try to help you to fix this problem
 
Also UTF-8 can't be used in this case, but only UTF-16
 
Eugeniy Lugovoy:
Also UTF-8 cannot be used in this case, but only UTF-16!
What does that mean? Does it mean to set database encoding with UTF-16? Or does it mean convert Chinese string to UTF-16?