database generic error code 5601

htraore  
void OnStart()
  {
  
           datetime lastCandleOpeningTime = TimeCurrent();
           bool result =true;
           string fileName = "BINARY OPTIONS.sqlite";
           int db = DatabaseOpen(fileName,DATABASE_OPEN_CREATE);

              //Open the database
           if(db == INVALID_HANDLE)
            {
               Alert("Database failed to create/open ",fileName, ". Error: ",GetLastError());
               return;               
            }
            
            //Create the table "results"
            if(DatabaseTableExists(db,"RESULTS"))
               {
                  //Delete the table
                  if(!DatabaseExecute(db,"DROP TABLE RESULTS"))
                     {
                        Alert("Database ",fileName, " failed to delete table 'RESULTS'. Error: ",
                        GetLastError());
                        DatabaseClose(db);
                        return;
                     }
               }
              //{ 
              if(!DatabaseExecute(db,"CREATE TABLE RESULTS ("
                  "Id INT PRIMARY KEY NOT NULL,"
                  "Expert INT NOT NULL,"
                  "Date INT NOT NULL,"
                  "Pair TEXT NOT NULL,"
                  "Results NUMERIC BOOLEAN NOT NULL);"))
               {
                  Alert("Database ",fileName, " failed to create table. Error: ",GetLastError());
                  DatabaseClose(db);
                  return;               
               }
              // }
           //Insert results in database
           string request = StringFormat("INSERT INTO RESULTS (Expert, Date, Pair,Results)"
                           "VALUES (%d,%d,'%s','%s');",EXPERT_MAGIC ,lastCandleOpeningTime, _Symbol, result);
           int prepareHandle = DatabasePrepare(db,request);
           if(prepareHandle == INVALID_HANDLE)
            {
               Alert("Request failed with error : ", GetLastError());
               DatabaseClose(db);
               return;
            } 
           else if(!DatabaseRead(prepareHandle))
            {
               Alert("Database ",fileName, " failed to insert data. Error : ", GetLastError());
               DatabaseClose(db);
               return;               
            }
           
   
  }

Hello everyone,

I face the same error code (5601) when trying to insert values in a table. I thought maybe it was a problem of type matching between the data to be inserted and the table fields. But all my attempts failed. Any help will be really appreciated. So the exact error is; 

"Database ",fileName, " failed to insert data. Error : 5601
OOP in MQL5 by Example: Processing Warning and Error Codes
OOP in MQL5 by Example: Processing Warning and Error Codes
  • www.mql5.com
Before we start developing, let's get acquainted with some features of the OOP, which will be used in this article.  Of course, we will use structures and classes. These are the basics of object oriented languages. A structure is a construction that allows containing a set of variables and functions of different types (except void). A class as...
htraore  
htraore:

Hello everyone,

I face the same error code (5601) when trying to insert values in a table. I thought maybe it was a problem of type matching between the data to be inserted and the table fields. But all my attempts failed. Any help will be really appreciated. So the exact error is; 

 I solved the problem. It was because of the "NOT NULL" specified for my Primary key. I should provide a value for it in the INSERT statement. Finally I choose to autoincrement it
Domestatre  
Thanks for posting .. had same problem
Reason: