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
nhatkhanguyen92:
I want to insert data into SQLite every tick but Error code: 5601
Someone please help me!
Thank you very much!
void OnTick() { string filename="EA_data_"+AccountInfoInteger(ACCOUNT_LOGIN)+".db"; string sql; int database=DatabaseOpen(filename, DATABASE_OPEN_READWRITE | DATABASE_OPEN_CREATE |DATABASE_OPEN_COMMON); sql = StringFormat("INSERT INTO Orders (id, account, name_chart, time_chart) VALUES (%d,%d,%s,%d)",(uint)TimeCurrent(),AccountInfoInteger(ACCOUNT_LOGIN),Symbol(),(uint)Period()); if(!DatabaseExecute(database, sql)){ Alert("Error Code: ", GetLastError()); } DatabaseClose(database); }

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I want to insert data into SQLite every tick but Error code: 5601
Someone please help me!
Thank you very much!