创建表单

| 发表于 2020-7-20 00:12:14 | 显示全部楼层 |复制链接
  1. //+------------------------------------------------------------------+
  2. //| Script program start function                                                   |
  3. //+------------------------------------------------------------------+
  4. void OnStart()
  5. {
  6.    string Host, User, Password, Database, Socket; // database credentials
  7.    int Port, ClientFlag;
  8.    int DB; // database identifier
  9.    Print (MySqlVersion());
  10.    string terminal_data_path = TerminalInfoString(TERMINAL_DATA_PATH);
  11.    string strDbConfig = terminal_data_path + "\\MQL4\\Scripts\\MyConnection.ini";
  12. // reading database credentials from INI file
  13.    Host = ReadIni(strDbConfig, "MYSQL", "Host");
  14.    User = ReadIni(strDbConfig, "MYSQL", "User");
  15.    Password = ReadIni(strDbConfig, "MYSQL", "Password");
  16.    Database = ReadIni(strDbConfig, "MYSQL", "Database");
  17.    Port     = StrToInteger(ReadIni(strDbConfig, "MYSQL", "Port"));
  18.    Socket   = ReadIni(INI, "MYSQL", "Socket");
  19.    ClientFlag = StrToInteger(ReadIni(strDbConfig, "MYSQL", "ClientFlag"));
  20.    Print ("Host: ", Host, ", User: ", User, ", Database: ", Database);
  21. // open database connection
  22.    Print ("Connecting...");
  23.    DB = MySqlConnect(Host, User, Password, Database, Port, Socket, ClientFlag);
  24.    if (DB == -1)
  25.       {
  26.          Print ("Connection failed! Error: " + MySqlErrorDescription);
  27.       }
  28.    else
  29.       {
  30.          Print ("Connected! DBID#", DB);
  31.       }
  32.    string Query;
  33.    Query = "DROP TABLE IF EXISTS `test_table`";
  34.    MySqlExecute(DB, Query);
  35.    Query = "CREATE TABLE `test_table` (id int, code varchar(50), start_date datetime)";
  36.    if (MySqlExecute(DB, Query))
  37.       {
  38.          Print ("Table `test_table` created.");
  39.       }
  40.    else
  41.       {
  42.          Print ("Table `test_table` cannot be created. Error: ", MySqlErrorDescription);
  43.       }
  44.    MySqlDisconnect(DB);
  45.    Print ("Disconnected. Script done!");
  46. }
复制代码
最近访问 头像模式
举报

评论 使用道具

发新帖
EA交易
您需要登录后才可以评论 登录 | 立即注册

精品外汇EA