Problems compiling expert that imports a DLL to connect to SQL

 

I am trying to create an expert that imports an external DLL to connect to PostgreSQL or MS SQL Server Express.

I found a library from SQLAPI++ that allows one to connect to any database; however, I can't get it to compile for the life of me.

Can someone help me with the syntax (its currently more C++ than MQL) to get this expert compiled and working?

>>

#import sqlapi.dll
 
#import
 
 
 
int init()
{
       SAConnection con; // create a connection object
   }
 
 int deinit() {}
 
 
 
int start()      {
               // connect to database
               con.Connect("localhost@test", "user", "pass",
                       SA_MySQL_Client);
               // For PostgreSQL
               // SA_PostgreSQL_Client);
 
               SACommand cmd(&con, // create command object
                       "insert into ticks"
                       "(margin,freemargin,date,ask,bid,symbol,equity) "
                       "values(:1, :2, :3, :4, :5, :6, :7)");
 
               // don't know the parameter types, but bind the
               // parameters, something like:
               cmd.Param(1).setAsLong() = AccountMargin();
               cmd.Param(2).setAsLong() = AccountFreeMargin();
               cmd.Param(3).setAsDateTime() =
                       SADateTime::CurrentTime();
               cmd.Param(4).setAsDouble() = Ask;
               cmd.Param(5).setAsDouble() = Bid;
               cmd.Param(6).setAsString() = OrderSymbol();
               cmd.Param(7).setAsLong() = AccountEquity();
 
               // execute command
               cmd.Execute();
       }
       catch(SAException &x)
       {
               // process errors
               Print("Error: %s\n", (const char*)x.ErrText());
 
}

<<

 

Look in the Sample folder of your MetaTrader for a Sample DLL.

That might give you a clue.

MQL4 syntax is is more a subset of C, not C++.

 
Ray:

Look in the Sample folder of your MetaTrader for a Sample DLL.

That might give you a clue.

MQL4 syntax is is more a subset of C, not C++.

Is there any such samples for MT5, please? Ive looked for them where they are for MT4 and they seemed to have either moved or dont exist.