| New signals service! | |
|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack (1) | Thread Tools | Display Modes |
|
|||
|
|||
|
Yes! Thats what I was looking for. libmysql.dll - where can I get it from? Is it avy special version?
NOTE: I've just downloaded MySQL 5.0 pack from mysql.com and grab it from INSTALATION_DIR/bin/libmysql.dll It works as a dream! Thank you again!!! Last edited by freak; 04-14-2006 at 07:53 AM. |
|
||||
|
for libmysql.dll look in "lib" subfolder of your mysql installation.
there is one problem though as metatrader can get only scalar datatypes from DLLs. DDL and DML SQL statements work just fine, but if you need to read something from database with SELECT, it is not so trivial as result is in memory as some structure, which can not be read in MQ4. to override this I had to output query result to a file and then read it in MQ4: Code:
int GetClientTrades() {
FileDelete(queryFile);
string query="SELECT * INTO OUTFILE \'"+queryPFile+"\' FIELDS TERMINATED BY \';\' LINES TERMINATED BY \'\n\'FROM clients_trades;";
Print(query);
int length=StringLen(query);
mysql_real_query(mysql,query,length);
int myerr=mysql_errno(mysql);
if (myerr>0) Print("error=",myerr);
int handle,res,size,i;
ArrayResize(clientTrades,0);
handle=FileOpen(queryFile,FILE_CSV|FILE_READ);
if(handle<1) {
Print("File " + queryFile + " not found, the last error is ", GetLastError());
return(0);
}
while (!FileIsEnding(handle)) {
size++;
ArrayResize(clientTrades,size);
clientTrades[size-1][0]=FileReadNumber(handle);
clientTrades[size-1][1]=FileReadNumber(handle);
clientTrades[size-1][2]=FileReadNumber(handle);
clientTrades[size-1][3]=FileReadNumber(handle);
clientTrades[size-1][4]=FileReadNumber(handle);
clientTrades[size-1][5]=FileReadNumber(handle);
clientTrades[size-1][6]=FileReadNumber(handle);
clientTrades[size-1][7]=FileReadNumber(handle);
clientTrades[size-1][8]=FileReadNumber(handle);
clientTrades[size-1][9]=FileReadNumber(handle);
}
ArrayResize(clientTrades,size-1);
size--;
//if (clientTrades[size-1][0]==0.0) ArrayResize(clientTrades,size-1);
FileClose(handle);
return(1);
}
|
|
|||
|
sorry to bring up an older thread but I have successfully connected and inserted data into a mysql database via the EA but I can't seem to figure out your code to SELECT data. I copied the function but it came up with a lot of errors.
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/metatrader-4/1670-can-mql-use-database-connection.html
|
||||
| Posted By | For | Type | Date | |
| mql - learn to trade forex swicki - powered by eurekster | This thread | Refback | 07-31-2007 11:33 AM | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Strange connection | prasxz | Metatrader 4 | 5 | 07-04-2008 10:14 AM |
| Ask about internet connection? | OhYes | Expert Advisors - Metatrader 4 | 1 | 11-20-2006 03:56 PM |
| No Connection | mart-hart | Metatrader 4 | 3 | 08-13-2006 05:52 AM |
| Using database connection in MQ | freak | Tools and utilities | 5 | 04-13-2006 08:00 PM |