//--- INCLUDES #include <MQH\Lib\SQLite3\SQLite3Base.mqh>
//--- VARIABLES
CSQLite3Base sql3;
CSQLite3Table testTable;
CSQLite3Cell testCell;
//+------------------------------------------------------------------+//||//+------------------------------------------------------------------+voidOnStart()
{
//--- OPEN DATABASE CONNECTIONif(sql3.Connect("test.db3")!=SQLITE_OK)
{Print(sql3.ErrorMsg()); DebugBreak(); return;}
elsePrint("CONNECTED TO DB.");
//--- CEATE TABLEif(sql3.Query("DROP TABLE IF EXISTS [test]")!=SQLITE_DONE)
{Print(sql3.ErrorMsg()); DebugBreak(); return;}
if(sql3.Query("CREATE TABLE [test] ([i] INT)")!=SQLITE_DONE)
{Print(sql3.ErrorMsg()); DebugBreak(); return;}
elsePrint("TABLE CREATED.");
//--- INSERT VALUEif(sql3.Query("INSERT INTO [test] VALUES(1)")!=SQLITE_DONE)
{Print(sql3.ErrorMsg()); DebugBreak(); return;}
elsePrint("VALUE \"1\" INSERTED.");
//--- COUNT TABLE ROWSif(sql3.Query(testTable,"SELECT COUNT(*) FROM [test]")!=SQLITE_DONE)
{Print(sql3.ErrorMsg()); DebugBreak(); return;}
testTable.Cell(0,0,testCell);
Print("RETRIEVED DATA FROM TABLE : Count(*)=",testCell.GetInt());
}
//+------------------------------------------------------------------+
+added Prints and test __int d0 inside int ViewInt() for comparison purposes
Print(__FUNCSIG__," || ENTER FUNCTION");
//--- TEST d0
__int d0={0}; Print ("TEST d0: d0.v=",d0.v, " DATA d.b:"); ArrayPrint(d0.b);
ViewArray(d0.b,0,4);
Print("ViewArray OUTPUT: d0.v=",d0.v," DATA d.b:"); ArrayPrint(d0.b);
//--- d - AS WAS+some Prints
__int d; d.v=0;Print("\n","d AS WAS: d.v=",d.v," DATA d.b:"); ArrayPrint(d.b);
ViewArray(d.b,0,4);
Print("ViewArray OUTPUT: d.v=",d.v, " DATA d.b:"); ArrayPrint (d.b);
//---return(d.v);
OUTPUT:
//CONNECTED TO DB.//TABLE CREATED.//VALUE "1" INSERTED.//int CSQLite3Cell::GetInt() || ENTER FUNCTION//int CSQLite3Cell::GetInt() || type=CT_INT case//int CByteImg::ViewInt() || ENTER FUNCTION//TEST d0: d0.v=0 DATA d.b://0 0 0 0//ViewArray OUTPUT: d0.v=1 DATA d.b://1 0 0 0// //d AS WAS: d.v=0 DATA d.b://0 0 0 0//ViewArray OUTPUT: d.v=0 DATA d.b://10 0 0//RETRIEVED DATA FROM TABLE : Count(*)=0
I read your code, @o_o, before writing previous posts and saw perfectly well that there is a union - that's why this bug seemed strange to me too, but it is obviously there.
However, I didn't find the bug in the lib(further down the code - in ViewArray and constructors__int). However, I can assume from what is highlighted in OUTPUT (obviously strange for union) that the "kind" compiler did not see the change in __int after ViewArray (which operates only .b) and returned the last known value for .v = 0 (highlighted) from the cache "without looking" at d. v itself.
But here I have only assumptions, because I haven't seen the compliator itself, and I repeat, I haven't found any errors related to this bug in your code.
rvkstudent: I get 2 warnings when running the script:
2017.09.26 07:39:35.569 SQLite3Test'C:\Users\Roman\AppData\Roaming\MetaQuotes\Terminal\MQL5\Libraries\sqlite3_32.dll' is not 64-bit version 2017.09.26 07:39:35.602 SQLite3Test (GAZP,H1) Cannot load 'C:\Users\Roman\AppData\Roaming\MetaQuotes\Terminal\MQL5\Libraries\sqlite3_32.dll' [193]
Both libraries 32 and 64 were in the archive. I have Win7 64. I don't understand - what do I need to do?
nothing
this is MT's reaction to import, but the code continues to work.
I realise it's hard to get any help from you. I'll just have to figure it out myself. Just keep in mind that your example doesn't work everywhere. I don't know why.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Test script:
+added Prints and test __int d0 inside int ViewInt() for comparison purposes
OUTPUT:
I read your code, @o_o, before writing previous posts and saw perfectly well that there is a union - that's why this bug seemed strange to me too, but it is obviously there.
However, I didn't find the bug in the lib(further down the code - in ViewArray and constructors __int) . However, I can assume from what is highlighted in OUTPUT (obviously strange for union) that the "kind" compiler did not see the change in __int after ViewArray (which operates only .b) and returned the last known value for .v = 0 (highlighted) from the cache "without looking" at d. v itself.
But here I have only assumptions, because I haven't seen the compliator itself, and I repeat, I haven't found any errors related to this bug in your code.
New article SQL and MQL5: Working with SQLite Database has been published:
Author: o_O
Hey man, great article.
Good afternoon,
I get 2 warnings when running the script:
2017.09.26 07:39:35.569 SQLite3Test 'C:\Users\Roman\AppData\Roaming\MetaQuotes\Terminal\MQL5\Libraries\sqlite3_32.dll' is not 64-bit version
Both libraries 32 and 64 were in the archive. I have Win7 64. I don't understand - what do I need to do?
I get 2 warnings when running the script:
2017.09.26 07:39:35.569 SQLite3Test 'C:\Users\Roman\AppData\Roaming\MetaQuotes\Terminal\MQL5\Libraries\sqlite3_32.dll' is not 64-bit version
2017.09.26 07:39:35.602 SQLite3Test (GAZP,H1) Cannot load 'C:\Users\Roman\AppData\Roaming\MetaQuotes\Terminal\MQL5\Libraries\sqlite3_32.dll' [193]
Both libraries 32 and 64 were in the archive. I have Win7 64. I don't understand - what do I need to do?
nothing
this is MT's reaction to import, but the code continues to work.
There is a fix for the PrintTable function in the appendix.
New article SQL and MQL5: Working with SQLite Database has been published:
Author: o_O
Do you have a 32 bits version ?
The issue is i have a lot of 32 bit customers...
Hello.
When I run SQLite3Test.mq5 I get error 14 (SQLITE_CANTOPEN). What am I doing wrong?
Hello.
When I run SQLite3Test.mq5 I get error 14 (SQLITE_CANTOPEN).
What am I doing wrong?
not debugging or logging the error location
do not debug or do not print the error location to the log
1. I run the script from the archive, "as is".
2. Debug "On real data". I enter the first function:
3. I get to this place in the SQLite3Base.mqh file:
4. After executing the line
int res=::sqlite3_open(file,m_db);I get res equal to 14. This is the end of the script.
Although, judging by the text of the article, it should be
"В результате работы появится файл базы данных в папке установки терминала MetaTrader 5."What can be the reason? Which way to look?
Checked the downloaded script
Everything worked correctly the first time
Serhii Shevchuk:
Which direction to look in?
start here
Checked the downloaded script
I checked it too:
Still error 14.
I realise it's hard to get any help from you. I'll just have to figure it out myself. Just keep in mind that your example doesn't work everywhere. I don't know why.