MQL4, ORACL, MSSQL, MySQL'den bir veritabanına nasıl erişilir - sayfa 5

 

Ve şöyle deneyin:

 #import "MT4"
int SaveSQL ( int x , int y ) ;   
#import

void start ( )
{
   int rez = SaveSQL ( 10 , 2 ) ;
   Comment ( "Результат" + rez ) ;
}
 
Bana mysql veritabanıyla çalışmak için kararlı bir çözüm söyleyin (bilgi okuma ve yazma). mysql_wrapper, terminali çökertmeye devam ediyor.
 

BTRVODKAex

bu amaçlar için, c++\cli'de bir ara dll yazılır. Doğrudan yönetilen kodu mql'den arayamazsınız



 
Graff >> :
Bana mysql veritabanıyla çalışmak için kararlı bir çözüm söyleyin (bilgi okuma ve yazma). mysql_wrapper, terminali çökertmeye devam ediyor.

https://www.mql5.com/ru/code/8623

 
HIDDEN >> :

https://www.mql5.com/ru/code/8623

mysql_wrapper kullanılırken terminal çöküyor. belki bunu düzeltmenin bir yolu vardır? Wine XP ve wine 7 build 7100 üzerinde test edilmiştir - aynı problemler.

Kayıt:

Kritik bir hata oluştu
Saat : 2009.07.03 13:38
Program : İstemci Terminali
Sürüm : 4.00 (yapı: 224, 15 Mayıs 2009)
İşletim Sistemi : Windows XP Professional 5.1 Service Pack 3 (Derleme 2600)
İşlemciler: 2 x X86 (seviye 6)
Bellek : 2086128/291388 kb
İstisna: C0000005
Adres : 7C929267
Erişim Türü : oku
Erişim Adresi: 00000004

Kayıtlar : EAX=00000000 CS=001b EIP=7C929267 EFLGS=00010217
: EBX=00000000 SS=0023 ESP=0012DD60 EBP=0012DE1C
: ECX=022F8900 DS=0023 ESI=022F88F0 FS=003b
: EDX=022F8910 ES=0023 EDI=00340000 GS=0000

Yığın İzleme : 77C1C2DE 0055ED21 00000000 00000000
: 00000000 00000000 00000000 00000000
: 00000000 00000000 00000000 00000000
: 00000000 00000000 00000000 00000000

Modüller :
1: 00400000 002B1000 d:\forex\metatrader - alpari\terminal.exe
2: 00F70000 00042000 c:\program dosyaları\splitview 2009\splat.dll
3: 018F0000 002CD000 c:\windows\system32\xpsp2res.dll
4 : 02050000 00035000 d:\forex\metatrader - alpari\experts\libraries\mysql_wrapper.dll
5 : 02090000 00244000 c:\windows\system32\libmysql.dll
6 : 02560000 00009000 c:\windows\system32\amhooker.dll
7 : 08000000 00008000 c:\program files\yandex\punto switcher\pshook.dll
8 : 10000000 00012000 c:\program dosyaları\rocketdock\rocketdock.dll
9:40080000 001E8000 c:\windows\system32\iertutil.dll
10:45020000 00131000 c:\windows\system32\urlmon.dll
11 : 5B260000 0038000 c:\windows\system32\uxtheme.dll
12 : 5BD50000 00056000 c:\windows\system32\netapi32.dll
13 : 61EC0000 0000E000 c:\windows\system32\mfc42loc.dll
14 : 698B0000 00058000 c:\windows\system32\hnetcfg.dll
15 : 71A30000 00040000 c:\windows\system32\mswsock.dll
16:71A70000 00008000 c:\windows\system32\wshtcpip.dll
17:71A80000 00008000 c:\windows\system32\ws2help.dll
18:71A90000 00017000 c:\windows\system32\ws2_32.dll
19 : 71AB0000 0000A000 c:\windows\system32\wsock32.dll
20 : 72CD0000 00008000 c:\windows\system32\msacm32.drv
21 : 72CE0000 00009000 c:\windows\system32\wdmaud.drv
22 : 73D90000 000FE000 c:\windows\system32\mfc42.dll
23 : 746E0000 0004C000 c:\windows\system32\msctf.dll
24:75310000 0002E000 c:\windows\system32\msctfime.ime
25 : 76350000 00005000 c:\windows\system32\msimg32.dll
26:76360000 0001D000 c:\windows\system32\imm32.dll
27:76380000 00049000 c:\windows\system32\comdlg32.dll
28 : 76B20000 0002E000 c:\windows\system32\winmm.dll
29 : 76BE0000 0000B000 c:\windows\system32\psapi.dll
30 : 76C20000 0002E000 c:\windows\system32\wintrust.dll
31 : 76C80000 00028000 c:\windows\system32\imagehlp.dll
32 : 76F10000 00027000 c:\windows\system32\dnsapi.dll
33 : 76F50000 0002D000 c:\windows\system32\wldap32.dll
34 : 76FA0000 00008000 c:\windows\system32\winrnr.dll
35 : 76FB0000 00006000 c:\windows\system32\rasadhlp.dll
36 : 76FC0000 0007F000 c:\windows\system32\clbcatq.dll
37 : 77040000 000C7000 c:\windows\system32\comres.dll
38:77110000 0008B000 c:\windows\system32\oleaut32.dll
39 : 773C0000 00103000 c:\windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.2600.5512_x-ww_35d4ce83\comctl32.dll
40 : 774D0000 0013E000 c:\windows\system32\ole32.dll
41 : 77910000 000F4000 c:\windows\system32\setupapi.dll
42 : 77A70000 00096000 c:\windows\system32\crypt32.dll
43 : 77B10000 00012000 c:\windows\system32\msasn1.dll
44 : 77B30000 00022000 c:\windows\system32\apphelp.dll
45 : 77BC0000 00007000 c:\windows\system32\midimap.dll
46 : 77BD0000 00015000 c:\windows\system32\msacm32.dll
47 : 77BF0000 00008000 c:\windows\system32\version.dll
48 : 77C00000 00058000 c:\windows\system32\msvcrt.dll
49 : 77DC0000 000AC000 c:\windows\system32\advapi32.dll
50 : 77E70000 00092000 c:\windows\system32\rpcrt4.dll
51 : 77F10000 00049000 c:\windows\system32\gdi32.dll
52 : 77F60000 00076000 c:\windows\system32\shlwapi.dll
53 : 77FE0000 00011000 c:\windows\system32\secur32.dll
54 : 7C800000 000F8000 c:\windows\system32\kernel32.dll
55 : 7C900000 000B3000 c:\windows\system32\ntdll.dll
56 : 7C9C0000 0081B000 c:\windows\system32\shell32.dll
57 : 7E360000 0091000 c:\windows\system32\user32.dll

çağrı yığını:


 

libmysql.dll kullanmanın nesi yanlış?

Veritabanına mükemmel yazıyor, okumayı denemedim, ama aynı zamanda pervazsız da varsayıyorum.

 
kombat >> :

libmysql.dll kullanmanın nesi yanlış?

Veritabanına mükemmel yazıyor, okumayı denemedim, ama aynı zamanda pervazsız da varsayıyorum.

Benim için veri tabanından okumak daha önemli. Birisinin libmysql.dll aracılığıyla veritabanından okumak için kanıtlanmış bir kodu varsa, lütfen gönderin.

İşte veritabanından libmysql.dll aracılığıyla okumak için kod:

 //+------------------------------------------------------------------+
//|                                                      news001.mq4 |
//|                                          Copyright © 2009, Graff |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Graff"
#property link      ""

#property indicator_chart_window

#define DELIM ";" 
//#include <mysql.mqh> 

#import "libmysql.dll" 
int mysql_init ( int db ) ; 
int mysql_errno ( int TMYSQL ) ; 
int mysql_real_connect ( int TMYSQL , string host , string user , string password , string DB , int port , int socket , int clientflag ) ; 
int mysql_real_query ( int TMSQL , string query , int length ) ; 
void mysql_close ( int TMSQL ) ; 

int mysql_store_result ( int TMSQL ) ; 
string mysql_fetch_row ( int result ) ; 
int mysql_num_rows ( int result ) ; 
void mysql_free_result ( int result ) ; 

//#import 

int mysql ; 

int mTicket , mType ; 
string mSymbol ; 
double mLots , mOpen , mClose , mStopLoss , mTakeProfit ;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init ( )
  {
//---- indicators
   string row ; 
   connect ( ) ; 
   string query = "Select currency, title from calendar WHERE currency = 'USD'" ; 
   int length = StringLen ( query ) ; 
   mysql_real_query ( mysql , query , length ) ; 
   int result = mysql_store_result ( mysql ) ; 
   int numOfRows = mysql_num_rows ( result ) ; 
   for ( int i = 0 ; i < numOfRows ; i + + ) { 
      row = mysql_fetch_row ( result ) ; 
      Print ( row ) ; 
      //Print("Ticket=", mTicket, ",Symbol=", mSymbol);
     // decodeTrade(row); 
      //Comment("Ticket=", mTicket, ",Symbol=", mSymbol, ",Type=", mType, ",Lots=", mLots, ",Open=", mOpen, ",Close=", mClose, ",SL=", mStopLoss, ",TakeProfit=", mTakeProfit); 
   } 
   mysql_free_result ( result ) ;
//----
   return ( 0 ) ;
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit ( )
  {
//----
 mysql_close ( mysql ) ;
//----
   return ( 0 ) ;
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start ( )
  {
   int    counted_bars = IndicatorCounted ( ) ;
//----
   
//----
   return ( 0 ) ;
  }
//+------------------------------------------------------------------+

void connect ( ) { 

   mysql = mysql_init ( mysql ) ; 
   if ( mysql ! = 0 ) Print ( "allocated" ) ; 
   string host = "localhost" ; 
   string user = "*****" ; 
   string password = "****" ; 
   string DB = "forex" ; 
   int clientflag = 0 ; 
   int port = 3306 ; 
   string socket = "" ; 
   int res = mysql_real_connect ( mysql , host , user , password , DB , port , socket , clientflag ) ; 
   int err = GetLastError ( ) ; 
   if ( res = = mysql ) Print ( "connected" ) ; 
   else Print ( "error=" , mysql , " " , mysql_errno ( mysql ) , " " ) ; 

} 

void decodeTrade ( string trade ) { 
   int begin = StringFind ( trade , DELIM ) + 1 ; 
   int end = StringFind ( trade , DELIM , begin ) ; 
   mTicket = StrToInteger ( StringSubstr ( trade , begin , end - begin ) ) ; 
   begin = end + 1 ; 
   end = StringFind ( trade , DELIM , begin ) ; 
   mSymbol = StringSubstr ( trade , begin , end - begin ) ; 
   begin = end + 1 ; 
   end = StringFind ( trade , DELIM , begin ) ; 
   mType = StrToInteger ( StringSubstr ( trade , begin , end - begin ) ) ; 
   begin = end + 1 ; 
   end = StringFind ( trade , DELIM , begin ) ; 
   mLots = StrToDouble ( StringSubstr ( trade , begin , end - begin ) ) ; 
   begin = end + 1 ; 
   end = StringFind ( trade , DELIM , begin ) ; 
   mOpen = StrToDouble ( StringSubstr ( trade , begin , end - begin ) ) ; 
   begin = end + 1 ; 
   end = StringFind ( trade , DELIM , begin ) ; 
   mClose = StrToDouble ( StringSubstr ( trade , begin , end - begin ) ) ; 
   begin = end + 1 ; 
   end = StringFind ( trade , DELIM , begin ) ; 
   mStopLoss = StrToDouble ( StringSubstr ( trade , begin , end - begin ) ) ; 
   begin = end + 1 ; 
   end = StringLen ( trade ) ; 
   mTakeProfit = StrToDouble ( StringSubstr ( trade , begin , end - begin ) ) ; 
} 


Yürütülmesinin sonucu:

18:01:54 'news001' derleniyor
18:01:54 news001 USDCHF,H4: başlatılmamış
18:01:54 news001 USDCHF,H4: uninit neden 2
18:01:54 news001 USDCHF,H4: başarıyla yüklendi
18:01:54 news001 USDCHF,H4: tahsis edildi
18:01:54 news001 USDCHF,H4: bağlı
18:01:54 news001 USDCHF,H4: ¤Fџ ЁFџ °Fџ USD
18:01:54 news001 USDCHF,H4: МFџ РFџ nFџ USD
18:01:54 news001 USDCHF,H4: Gџ Gџ $Gџ USD
18:01:54 news001 USDCHF,H4: DGџ HGџ _Gџ USD
18:01:54 news001 USDCHF,H4: |Gџ ЂGџ ™Gџ USD
18:01:54 news001 USDCHF,H4: јGџ AGџ YGџ USD
18:01:54 news001 USDCHF,H4: üGџ
18:01:54 news001 USDCHF,H4:,Hџ 0Hџ FHџ USD
18:01:54 news001 USDCHF,H4: dHџ hHџ wHџ USD
18:01:54 news001 USDCHF,H4: ”Hџ ˜Hџ “Hџ USD
18:01:54 news001 USDCHF,H4: МHџ РHџ kHџ USD
18:01:54 news001 USDCHF,H4: Iџ Iџ Iџ USD vb.


Hiyerogliflerle sorunu bir şekilde çözebilir miyim? Aynı isteğin phpMyAdmin'deki ekran görüntüsü



 

MS SQL veritabanıyla çalışmak için "sarmalayıcıyı" yaydım

ADOLib.mqh sarmalayıcısı ve COM sunucusunun kendisi,

MS SQL (sadece değil!) ADOLib.dll ile çalışmayı sağlar.

ADOLib.mqh şöyle görünür:


// enum CursorTypeEnum için sabitler

#define adOpenBelirtilmemiş 4294967295 //$FFFFFFFF;
#define adOpenForwardOnly 0 //$00000000;
#define adOpenKeyset 1 //$00000001;
#define adOpenDynamic 2 //$00000002;
#define adOpenStatic 3 //$00000003;

// enum LockTypeEnum için sabitler

#define adLockBelirtilmemiş 4294967295 //$FFFFFFFF;
#define adLockReadOnly 1 //$00000001
#define adLockPessimistic 2 //$00000002;
#define adLockOptimistic 3 //$00000003;
#define adLockBatchOptimistic 4 //$00000004;

// enum ExecuteOptionEnum için sabitler

#define adOptionBelirtilmemiş 4294967295 //$FFFFFFFF;
#define adAsyncExecute 16 //$00000010;
#define adAsyncFetch 32 //$00000020;
#define adAsyncFetchNonBlocking 64 //$00000040;
#define adExecuteNoRecords 128 //$00000080;
#define adExecuteStream 296 //$000000400;
#define adExecuteRecord 2048 //$000000800;

// enum CursorLocationEnum için sabitler

#define adUseNone 1 //$00000001;
#define adUseServer 2 //$00000002;
#define adUseClient 3 //$00000003;
#define adUseClientBatch 3 //$00000003;

// enum CommandTypeEnum için sabitler

#define adCmdBelirtilmemiş 4294967295 //$FFFFFFFF;
#define adCmdUnknown 8 //$00000008;
#define adCmdText 1 //$00000001;
#define adCmdTable 2 //$00000002;
#define adCmdStoredProc 4 //$00000004;
#define adCmdFile 256 //$000000100;
#define adCmdTableDirect 512 //$000000200;

#import "ADOLib.dll"
int CreateConnection();
intDestroyConnection();
int OpenConnection(string ConnectionString,int CursorLocation,int CommandTimeout);
intCloseConnection();
int IsOpenConnection();
int Execute(string CommandText, int ExecuteOption);
intBeginTrans();
intCommitTrans();
int RollbackTrans();
int OpenTable(string Qry,int CursorLocation,int CursorType,int LockType,int Seçenekler);
intCloseTable();
intRequest();
int Güncelleme();
int UpdateBatch();
int İptal();
int CancelBatch();
int CancelUpdate();
int Bul(dize Kriterleri,int AramaYön,int Başlangıç);
int Filtre(dizi Kriterleri);
intBOF();
intEOF();
intMoveFirst();
intMoveLast();
intMoveNext();
string TableStatus();
intFieldsCount();
string AlanAdı(int I);
string FieldType(int Adı);
string FieldTypeByPos(int I);
string GetFieldValue(dize Adı);
string GetFieldValueByPos(int I);
int SetFieldValue(stringName);
int SetFieldValueByPos(int I);



 

MS SQL 2005 "dbForex" veritabanına bağlanma örneği

int createCnn=0;
int openCnn=0;
intInsert=0;

string StringConnection="DSN=dbForex;UID=sa;PWD=;";


int init()
{


Yakın bağlantı();
DestroyConnection();

int createCnn=CreateConnection();
uyku(10);

int openCnn=OpenConnection(StringConnection,adUseClient,0);
uyku(10);


dönüş(0);
}


İş örneği:

int başlangıç()
{
//bu, bağlantının kapalı veya "bozuk" olması durumunda geçerlidir - yeterli neden var
if (createCnn<=0 || IsOpenConnection()==0)
{
createCnn=0;
openCnn=0;

Yakın bağlantı();
uyku(10);

DestroyConnection();
uyku(10);

createCnn=CreateConnection();
Uyku(30);
}

if (createCnn>0 &&(openCnn<=0 || IsOpenConnection()==0 || Insert==0))
{
openCnn=0;

Yakın bağlantı();
uyku(10);

openCnn=OpenConnection(StringConnection,adUseClient,0);
Uyku(30);
}


// ve sonra veri tabanına keneler yaz

stringCompany=HesapCompany();
string Symb=Sembol();

string CommandText="INSERT INTO Rates (TimeCurrent,AccountCompany,Symb,DateTimeRate,Ask,Bid)"+
"DEĞERLER("+TimeCurrent()+",'"+Şirket+"','"+Symb+"','"+DateTimeRate+"',"+Ask+","+Teklif+");
Execute(CommandText,adAsyncFetch);
uyku(15);

}


//+------------------------------------------- --------------------+
//| uzman sıfırlama işlevi |
//+------------------------------------------- --------------------+
int tanım()
{
Yakın bağlantı();
DestroyConnection();

dönüş(0);
}

 

ADOLib.mqh dosyasının "include" dizininde olduğuna inanıyorum ve

ADOLib "Kütüphane" dizininde.

Şimdi, \Library dizininde olmak kaydıyla

bu COM nesnesini seçin ve regsvr32 ADOLib.dll komutunu yazın,

Enter'a basın ve bu kitaplık kaydedilecek,

tüm bunlar komut satırı konsolundan veya

Total Commander'dan söyle.

Vista kullanıyorsanız, hem TC'yi hem de

konsol hesabın altından başlatılmalıdır

"Yönetici".

Neden: