mcqueccu Expert Licensed User Longtime User Jan 8, 2018 #1 How to I set and Get correct DBVersion in SQL Browser and my application. From the sample code below, I get result as 1 meanwhile, in building the database, I set user version as 15. Screenshot below What am i doing wrong. Also included example project Code: If File.Exists(File.DirInternal,"db.db") = False Then File.Copy(File.DirAssets,"db.db",File.DirInternal,"db.db") Log("DB Copied") End If sql.Initialize(File.DirInternal,"db.db",True) Log(DBUtils.GetDBVersion(sql)) Attachments dbversion.zip dbversion.zip 11.4 KB · Views: 630
How to I set and Get correct DBVersion in SQL Browser and my application. From the sample code below, I get result as 1 meanwhile, in building the database, I set user version as 15. Screenshot below What am i doing wrong. Also included example project Code: If File.Exists(File.DirInternal,"db.db") = False Then File.Copy(File.DirAssets,"db.db",File.DirInternal,"db.db") Log("DB Copied") End If sql.Initialize(File.DirInternal,"db.db",True) Log(DBUtils.GetDBVersion(sql))
eurojam Well-Known Member Licensed User Longtime User Jan 8, 2018 #2 you can use PRAGMA user_version; to get the user_version and PRAGMA user_version=5; to set the userversion Upvote 0
you can use PRAGMA user_version; to get the user_version and PRAGMA user_version=5; to set the userversion
mcqueccu Expert Licensed User Longtime User Jan 8, 2018 #3 eurojam said: you can use PRAGMA user_version; to get the user_version and PRAGMA user_version=5; to set the userversion Click to expand... PRAGMA user_version gives 15 as i have set in the Sqlite Database but I get different result in the app ( 1 ) when I use dbversion from DBUtils Class.. How come there is difference and how can i merge the two? Upvote 0
eurojam said: you can use PRAGMA user_version; to get the user_version and PRAGMA user_version=5; to set the userversion Click to expand... PRAGMA user_version gives 15 as i have set in the Sqlite Database but I get different result in the app ( 1 ) when I use dbversion from DBUtils Class.. How come there is difference and how can i merge the two?
Erel B4X founder Staff member Licensed User Longtime User Jan 8, 2018 #4 See how it is implemented. It creates a table for the version. It is not related to any other version information. Upvote 0
See how it is implemented. It creates a table for the version. It is not related to any other version information.
DonManfred Expert Licensed User Longtime User Jan 8, 2018 #5 mcqueccu said: but I get different result in the app ( 1 ) when I use dbversion from DBUtils Class.. Click to expand... you only copy the DB from your asset to somewhere when the file DOES NOT EXISTS. So, updating your app you already HAVE a version copied. The old one. But you are not copying a new databasefile. You need to update your local DB first with the changes needed to make it version 15..... Upvote 0
mcqueccu said: but I get different result in the app ( 1 ) when I use dbversion from DBUtils Class.. Click to expand... you only copy the DB from your asset to somewhere when the file DOES NOT EXISTS. So, updating your app you already HAVE a version copied. The old one. But you are not copying a new databasefile. You need to update your local DB first with the changes needed to make it version 15.....
mcqueccu Expert Licensed User Longtime User Jan 8, 2018 #6 DonManfred said: you only copy the DB from your asset to somewhere when the file DOES NOT EXISTS. So, updating your app you already HAVE a version copied. The old one. But you are not copying a new databasefile. You need to update your local DB first with the changes needed to make it version 15..... Click to expand... This happened with a fresh database running for first time. The 15 was set in the new database outside the application. Can you help me with a sample code on how to update the localDB Upvote 0
DonManfred said: you only copy the DB from your asset to somewhere when the file DOES NOT EXISTS. So, updating your app you already HAVE a version copied. The old one. But you are not copying a new databasefile. You need to update your local DB first with the changes needed to make it version 15..... Click to expand... This happened with a fresh database running for first time. The 15 was set in the new database outside the application. Can you help me with a sample code on how to update the localDB
DonManfred Expert Licensed User Longtime User Jan 8, 2018 #7 mcqueccu said: This happened with a fresh database running for first time Click to expand... so the one in your assets IS the most up to date database-file? If yes, then you should get the 15 as result as the database was not existent at the first run. Or not? The point is that you DID MADE some changes to the databasestructure (ony your pc probably). You need to remember all these changes. Updated table x and adding field y. removing field z. whatever..... In you app you then check the db. If it is V1 then you need to run the changes on the device database too.... Update table x and adding field y. removing field z. whatever..... You then set the version to V2 after all changes are done. Upvote 0
mcqueccu said: This happened with a fresh database running for first time Click to expand... so the one in your assets IS the most up to date database-file? If yes, then you should get the 15 as result as the database was not existent at the first run. Or not? The point is that you DID MADE some changes to the databasestructure (ony your pc probably). You need to remember all these changes. Updated table x and adding field y. removing field z. whatever..... In you app you then check the db. If it is V1 then you need to run the changes on the device database too.... Update table x and adding field y. removing field z. whatever..... You then set the version to V2 after all changes are done.