LucaMs Expert Licensed User Longtime User Sep 2, 2020 #1 This query: SELECT * FROM Table1 WHERE OneDate = #31/08/2020# works perfectly in Access sw, raises an error in b4j using ucanaccess library. Attachments UCanAccessTest.zip UCanAccessTest.zip 16 KB · Views: 688 Last edited: Sep 2, 2020
This query: SELECT * FROM Table1 WHERE OneDate = #31/08/2020# works perfectly in Access sw, raises an error in b4j using ucanaccess library.
Philip Chatzigeorgiadis Active Member Licensed User Longtime User Sep 2, 2020 #2 LucaMs said: Although practically empty (one table, one row, one field) the file has a size of 139MB! Click to expand... It might be helpful to try "Compact and Repair Database". Upvote 0
LucaMs said: Although practically empty (one table, one row, one field) the file has a size of 139MB! Click to expand... It might be helpful to try "Compact and Repair Database".
LucaMs Expert Licensed User Longtime User Sep 2, 2020 #3 Philip Chatzigeorgiadis said: It might be helpful to try "Compact and Repair Database". Click to expand... Yes, done right now (few minutes ago). Thank you. Upvote 0
Philip Chatzigeorgiadis said: It might be helpful to try "Compact and Repair Database". Click to expand... Yes, done right now (few minutes ago). Thank you.
Jorge M A Well-Known Member Licensed User Longtime User Sep 2, 2020 #4 Please try changing the query with cDate function, (without pound signs) B4X: Copy Dim Query As String = $"SELECT * FROM Table1 WHERE OneDate = cDate('${SomeDate}')"$ (assuming the column is a TIMESTAMP type) Upvote 0
Please try changing the query with cDate function, (without pound signs) B4X: Copy Dim Query As String = $"SELECT * FROM Table1 WHERE OneDate = cDate('${SomeDate}')"$ (assuming the column is a TIMESTAMP type)
LucaMs Expert Licensed User Longtime User Sep 2, 2020 #5 Jorge M A said: (assuming the column is a TIMESTAMP type) Click to expand... It is DateTime, then cDate is not needed (I tried anyway) and the error remains. Upvote 0
Jorge M A said: (assuming the column is a TIMESTAMP type) Click to expand... It is DateTime, then cDate is not needed (I tried anyway) and the error remains.
OliverA Expert Licensed User Longtime User Sep 2, 2020 #6 1) What was the error message? Mine was net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::4.x.x unknown token: in statement [SELECT * FROM Table1 WHERE OneDate = #31/08/2020#] Click to expand... 2) I changed the date to good ol US thinking 08/31/2020 and it worked 3) To get your sample going I had to block out this code block in InitDB Code: Copy If Result Then Try If Not(File.Exists(File.DirApp, accDBName)) Then File.Copy(File.DirAssets, accDBName, File.DirApp, accDBName) End If AccDB.InitializeSQLite(File.DirApp, accDBName, False) Catch Log(LastException) Result = False End Try End If Upvote 0
1) What was the error message? Mine was net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::4.x.x unknown token: in statement [SELECT * FROM Table1 WHERE OneDate = #31/08/2020#] Click to expand... 2) I changed the date to good ol US thinking 08/31/2020 and it worked 3) To get your sample going I had to block out this code block in InitDB Code: Copy If Result Then Try If Not(File.Exists(File.DirApp, accDBName)) Then File.Copy(File.DirAssets, accDBName, File.DirApp, accDBName) End If AccDB.InitializeSQLite(File.DirApp, accDBName, False) Catch Log(LastException) Result = False End Try End If
LucaMs Expert Licensed User Longtime User Sep 2, 2020 #7 OliverA said: 1) What was the error message? Mine was Click to expand... In my real project I get the same error message as you; in the test project I attached, I get a different one; this: java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near "#31": syntax error) OliverA said: 2) I changed the date to good ol US thinking 08/31/2020 and it worked Click to expand... I had already tried to change the format of the past date as a parameter, but having the doubt of having tried in the real project, I tried again in the attached project and I get the same error: java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near "#08": syntax error) OliverA said: To get your sample going I had to block out this code block in InitDB Click to expand... ? Upvote 0
OliverA said: 1) What was the error message? Mine was Click to expand... In my real project I get the same error message as you; in the test project I attached, I get a different one; this: java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near "#31": syntax error) OliverA said: 2) I changed the date to good ol US thinking 08/31/2020 and it worked Click to expand... I had already tried to change the format of the past date as a parameter, but having the doubt of having tried in the real project, I tried again in the attached project and I get the same error: java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near "#08": syntax error) OliverA said: To get your sample going I had to block out this code block in InitDB Click to expand... ?
LucaMs Expert Licensed User Longtime User Sep 2, 2020 #8 OliverA said: 3) To get your sample going I had to block out this code block in InitDB Click to expand... I did it too, of course with leaving there the copy line, and now it works (even with date 31/08/2020). Evidently the db file was corrupt. Thank you all Upvote 0
OliverA said: 3) To get your sample going I had to block out this code block in InitDB Click to expand... I did it too, of course with leaving there the copy line, and now it works (even with date 31/08/2020). Evidently the db file was corrupt. Thank you all
LucaMs Expert Licensed User Longtime User Sep 2, 2020 #9 LucaMs said: I did it too, of course with leaving there the copy line, and now it works (even with date 31/08/2020). Evidently the db file was corrupt. Thank you all Click to expand... Forget it; deleting that part, the test is not executed, this is why I get no error. Upvote 0
LucaMs said: I did it too, of course with leaving there the copy line, and now it works (even with date 31/08/2020). Evidently the db file was corrupt. Thank you all Click to expand... Forget it; deleting that part, the test is not executed, this is why I get no error.
LucaMs Expert Licensed User Longtime User Sep 2, 2020 #10 Now I get: net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::4.0.4 unknown token: even in the test project Upvote 0
Now I get: net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::4.0.4 unknown token: even in the test project
OliverA Expert Licensed User Longtime User Sep 2, 2020 #11 Here is your project, working for me, with the block mentioned above blocked out. The test is executed. I did not repair the DB, I did nothing else but block out the code and change the date format. Attachments UCanAccessTest_OliverA.zip UCanAccessTest_OliverA.zip 16 KB · Views: 549 Upvote 0
Here is your project, working for me, with the block mentioned above blocked out. The test is executed. I did not repair the DB, I did nothing else but block out the code and change the date format.
LucaMs Expert Licensed User Longtime User Sep 2, 2020 #12 Trying the last version of UCanAccess (5.0)... Upvote 0
LucaMs Expert Licensed User Longtime User Sep 2, 2020 #13 OliverA said: I did not repair the DB, Click to expand... I did it and updated the project attached. Trying your project... Upvote 0
OliverA said: I did not repair the DB, Click to expand... I did it and updated the project attached. Trying your project...
OliverA Expert Licensed User Longtime User Sep 2, 2020 #14 LucaMs said: Trying the last version of UCanAccess (5.0)... Click to expand... That was going to be my question: Why are you using 4.0.4? If you are trying to be cross platform with B4A (4.0.4 is the last version working in Android) I would understand, otherwise, why not use the newest? Upvote 0
LucaMs said: Trying the last version of UCanAccess (5.0)... Click to expand... That was going to be my question: Why are you using 4.0.4? If you are trying to be cross platform with B4A (4.0.4 is the last version working in Android) I would understand, otherwise, why not use the newest?
LucaMs Expert Licensed User Longtime User Sep 2, 2020 #15 LucaMs said: I did it and updated the project attached. Trying your project... Click to expand... ... and your project works. Also, I found the error... Creating the test project, I used the real project, removing what not needed but keeping and badly changing part of it: AccDB.Initialize("net.ucanaccess.jdbc.UcanaccessDriver", "jdbc:ucanaccess://" & AccDBPath) but after that... AccDB.InitializeSQLite(File.DirApp, accDBName, False) (the real project imports data from Access to SQLite). Upvote 0
LucaMs said: I did it and updated the project attached. Trying your project... Click to expand... ... and your project works. Also, I found the error... Creating the test project, I used the real project, removing what not needed but keeping and badly changing part of it: AccDB.Initialize("net.ucanaccess.jdbc.UcanaccessDriver", "jdbc:ucanaccess://" & AccDBPath) but after that... AccDB.InitializeSQLite(File.DirApp, accDBName, False) (the real project imports data from Access to SQLite).
LucaMs Expert Licensed User Longtime User Sep 2, 2020 #16 OliverA said: why not use the newest? Click to expand... Because you need to know that you are not using the latest version ? (I rarely used ucanaccess). Upvote 0
OliverA said: why not use the newest? Click to expand... Because you need to know that you are not using the latest version ? (I rarely used ucanaccess).
OliverA Expert Licensed User Longtime User Sep 2, 2020 #17 LucaMs said: ... and your project works. Click to expand... I just updated to use UCanAccess 5.0.0 and even it wants US collation on the date. Go figure... (Note: I'm not a UCanAccess expert) Upvote 0
LucaMs said: ... and your project works. Click to expand... I just updated to use UCanAccess 5.0.0 and even it wants US collation on the date. Go figure... (Note: I'm not a UCanAccess expert)
Jorge M A Well-Known Member Licensed User Longtime User Sep 2, 2020 #18 Just for the record: with cDate function the date format does not matter, as long as it is valid, the conversion from string to date is done internally , and you remove the ugly #'s. Code: Copy @FunctionType(functionName = "CDATE", argumentTypes = { AccessType.MEMO }, returnType = AccessType.DATETIME) public static Timestamp cdate(String dt) { return dateValue(dt); } Upvote 0
Just for the record: with cDate function the date format does not matter, as long as it is valid, the conversion from string to date is done internally , and you remove the ugly #'s. Code: Copy @FunctionType(functionName = "CDATE", argumentTypes = { AccessType.MEMO }, returnType = AccessType.DATETIME) public static Timestamp cdate(String dt) { return dateValue(dt); }
OliverA Expert Licensed User Longtime User Sep 2, 2020 #19 Just tested #2020-08-31# and #2020-8-31# and it works (with 4.0.4 and 5.0.0). So using a / it expects US collation and with - it wants yyyy-mm-dd format (note: this is not a language specific string format specification, it just means 4 digit year, one or two digit month and one or two digit date) Upvote 0
Just tested #2020-08-31# and #2020-8-31# and it works (with 4.0.4 and 5.0.0). So using a / it expects US collation and with - it wants yyyy-mm-dd format (note: this is not a language specific string format specification, it just means 4 digit year, one or two digit month and one or two digit date)
LucaMs Expert Licensed User Longtime User Sep 2, 2020 #20 OliverA said: Just tested #2020-08-31# and #2020-8-31# Click to expand... Upvote 0