I am using the following lines in a web app in the event handler Opening.
Purpose is to check if the database is available or not. At the very first start the db is not there because it must be generated by an admin. BUT: Xojocloud tells me that the file is there, which of course brings up lots of other errors afterwards. But the file CANNOT be there, because it is a new deployment.
Dim dbFile As New FolderItem("db.sqlite", FolderItem.PathModes.Native)
If dbFile.Exists Then
'MessageBox("DB exists")
What am I doing wrong?
What must I do to be able to deploy it on Xojocloud?
It is working on my local machine starting it from XoJo-Ide.
When you deploy to Xojo Cloud, any files that existed in a previous version of your app does not get deleted. Having looked at your server, there is a .sqlite file at the top level of your app directory.
One problem I do see however is that you’ve deployed two apps using the same domain. One called SKOnlineAnmeldung and one called SKOnlineAnmeldung2. They both reside in the same directory because they have the same domain name assigned to them. Xojo Cloud will only direct traffic to one of those apps so this is probably the cause of your issue.
Hi Jason and Greg,
yes, I tried Jason’s proposal (“dbabc.sqlite”) and it did not find it.
The reason is obviously, that files (= the database, which is created by the app) is not deleted when you deploy the app another time.
Knowing this, I always delete the app before a new deployment.
I found out that it works if i DO NOT encrypt the database.
I seems that the encrypted databases is not recognized as a database (Error: file is not a database) when it is encrypted.
On my local machine it works.
Here is the code I use in the opening event of the session:
Dim dbFile As New FolderItem("skanmeld.sqlite", FolderItem.PathModes.Native)
If dbFile.Exists Then
'MessageBox("DB exists")
Var d As DateTime = DateTime.Now
Var glDB As New SQLiteDatabase
VAR SQL as string
glDB.DatabaseFile = New FolderItem("skanmeld.sqlite")
Try
glDB.EncryptionKey = "123"
glDB.Connect
glDB.ExecuteSQL("BEGIN TRANSACTION")
SQL="INSERT INTO Sessions (Datum) VALUES('"+d.ToString+"')"
glDB.ExecuteSQL(SQL)
glDB.CommitTransaction
Var rows As RowSet
rows = glDB.SelectSQL("SELECT * FROM Sessions")
If rows <> Nil Then
rows.MovetoLastRow
SessionID =rows.Column("ID").Value
rows.Close
WebPage1.ShowLabelSessionID(SessionID)
End If
glDB.close
Catch error As DatabaseException
MessageBox("Error: " + error.Message)
End Try
So what am I doing wrong here?
Or does XojoCloud not support encrypted databases?
Dim dbFile As New FolderItem("skanmeld.sqlite", FolderItem.PathModes.Native)
If dbFile.Exists Then
sytem.log system.loglevelcritical,
Var d As DateTime = DateTime.Now
Var glDB As New SQLiteDatabase
VAR SQL as string
glDB.DatabaseFile = New FolderItem("skanmeld.sqlite")
Try
glDB.EncryptionKey = "123"
glDB.CreateDatabase // Create the db if not existing
glDB.BeginTransaction
SQL="INSERT INTO Sessions (Datum) VALUES(?)"
glDB.ExecuteSQL(SQL, d)
glDB.CommitTransaction
Var rows As RowSet
rows = glDB.SelectSQL("SELECT * FROM Sessions")
If rows <> Nil Then
rows.MovetoLastRow
SessionID =rows.Column("ID").Value
rows.Close
WebPage1.ShowLabelSessionID(SessionID)
End If
glDB.close
Catch error As DatabaseException
// Where in xojo cloud can one see the log messages?
sytem.log system.loglevelcritical, "DatabaseException: " + error.message
End Try
End If
Hello everybody,
shame on me: There is another connect to the database further down in the same procedure. And there I forgot to set the EncryptionKey.
With the set EncryptionKey there is no more error.
Thanks everybody for offering help.
I have learned something new.