string query = "DELETE FROM Trade WHERE ticket='" + IntegerToString((long)ticket) + "';";
i just tested my friends and not go return me this
2025.10.23 14:52:16.609 MONITOR_TRADE (ETHUSD,M15) IL TICKET E' 22117593 2025.10.23 14:52:16.609 MONITOR_TRADE (ETHUSD,M15) LAQUESRY DEL CAZZO E DELETE FROM Trade WHERE ticket='22117593'; 2025.10.23 14:52:16.610 MONITOR_TRADE (ETHUSD,M15) database error, near "131073": syntax error 2025.10.23 14:52:16.610 MONITOR_TRADE (ETHUSD,M15) Errore cancellazione DB | Ticket: 22117593 | Errore: 5601
if i execute this DELETE FROM Trade WHERE ticket='22117593'; inside a db browser erase correctly the record but if i run it by mql5 not work and return me error
i just tryed also in this mode void DeleteTradeFromDB(ulong ticket) { int db = DatabaseOpen(dbFile, DATABASE_OPEN_READWRITE); if(db == INVALID_HANDLE) { PrintFormat(" Errore apertura DB (%d)", GetLastError()); return; } string sql = "DELETE FROM Trade WHERE ticket=?"; // placeholder int stmt = DatabasePrepare(db, sql); if(stmt == INVALID_HANDLE) { PrintFormat(" Errore preparazione query (%d)", GetLastError()); DatabaseClose(db); return; } // 🔹 bind del parametro (come testo, in base a come è salvato nel DB) DatabaseBind(stmt, 0, (long)ticket); if(DatabaseExecute(db,stmt)) PrintFormat(" Trade %I64u rimosso correttamente dal DB", ticket); else PrintFormat(" Errore esecuzione DELETE per ticket=%I64u | codice=%d", ticket, GetLastError()); DatabaseFinalize(stmt); DatabaseClose(db); }
The error is likely caused by an unexpected character or the trailing semicolon, which DatabasePrepare might not accept.
Try removing the ";" and make sure you're using plain single quotes. If it still fails, the query string might contain hidden characters or SQLite could be misinterpreting the value; in that case, using DatabaseBind() with a parameter would be the safest way to rule that out.
i just tested my friends and not go return me this
if i execute this DELETE FROM Trade WHERE ticket='22117593'; inside a db browser erase correctly the record but if i run it by mql5 not work and return me error
Your code is buggy and overly complicated. Please read the documentation more carefully.
long ticket = 22117593; string sql = StringFormat("DELETE FROM Data4 WHERE ticket=%lli;",ticket); if(DatabaseExecute(db,sql)) PrintFormat(" Trade %I64u rimosso correttamente dal DB", ticket); else PrintFormat(" Errore esecuzione DELETE per ticket=%I64u | codice=%d", ticket, GetLastError());
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys i have a database sqlite
structure:
with this data :
i want remove the data without drop table only data i try to use this function for do that but return me always error
the error:
anyone have some idea or example? i not find a clear example for do that thanks