1. Fabrizio
  2. as SQLite DB Server
  3. Tuesday, August 18 2020, 04:42 PM
  4.  Subscribe via email
I’m migrating my existing project in Xojo (2019 3.2) and my existing SQLite database (1 table, and 1 virtual table created with FTS5 to use full search) and some triggers to make stay in sync the 2 tables, in Valentina SQLiteServer.
I’m now on my MBP (develop and debug purpose) where i’ve not installed server (and i’m not connected to my network).
So i’ve now on my MPB my SQLite database in my special folder Application Data.
In open app event i have modify the existing code with this code (do you think is ok) ?

DB = new VSQLiteDatabase

#If DebugBuild then

Var dbFile As FolderItem = SpecialFolder.ApplicationData.Child("NiP/NiP.db";)
DB.DatabaseFile = dbFile
Try
DB.Connect()
Catch err As DatabaseException
MessageBox ("Errore: " + err.Message)
Return
End Try

#ElseIf TargetMacOS then

if ArchivioInRete = "SI" then
DB.Host = "localhost"
DB.UserName = "sa"
DB.Password = "sa"
DB.Port = 15532
DB.databaseName = "NiP.db"
Try
DB.Connect()
Catch err As DatabaseException
MessageBox ("Errore: " + err.Message)
Return
End Try
End If

If ArchivioInRete = "NO" Then
rbArchivioInReteNO.Value = True

Var dbFile As FolderItem = SpecialFolder.ApplicationData.Child("NiP/NiP.db";)
DB.DatabaseFile = dbFile
Try
DB.Connect()
Catch err As DatabaseException
MessageBox ("Errore: " + err.Message)
Return
End Try

end if

#EndIf

I've added to my Xojo (i'm running on Mac OS X 10.15.6) Valentina plugin and declare DB as VSQLiteDatabase.
Now in Debug Build on MBP when execute this query:
DB.AddRow(“Notifiche”, row)
I receive this error: ERROR DB UNKNOWN and in the debugger:
Database exception ErrorNumber 427264

Why ? How to solve that ?
Thanks
Comment
There are no comments made yet.
Ruslan Zasukhin Accepted Answer
Sergey have point me, that in the Example databaseName is assigned AFTER DB.connect().

if( gClient ) then
db.Host = "localhost"
db.UserName = "sa"
db.Password = "sa"
db.Port = 15532 // optional. You can change port for SQLite DB connections in the VServer.ini file.
Connected = db.Connect()
if Connected then
// only NOW we specify db_name, and do create on remote Valentina SQLite Server. Must be ADMIN.
db.databaseName = "vsqlitetest.sqlite"
Connected = db.CreateDatabaseFileEx() // assign again into the same variable, will be TRUE if db was created under VServer, so we can use DB.
end if
else
Dim db_file as FolderItem = getFolderItem("vsqlitetest.sqlite")
db.DatabaseFile = db_file
Connected = db.CreateDatabaseFile() // TRUE if db was created.
end if
Comment
There are no comments made yet.
  1. more than a month ago
  2. as SQLite DB Server
  3. # 1
Ruslan Zasukhin Accepted Answer
But please also provide more explains about your environment

* did you read pages?
* did you try examples?
* did you install VServer to you MBP or other mac?
Comment
There are no comments made yet.
  1. more than a month ago
  2. as SQLite DB Server
  3. # 2
Fabrizio Accepted Answer
Hi Ruslan, thanks for the reply and support.

Yes i've read the various wiki.
I've installed the VServer only on my Mac Mini Server, but on my MBP (used only for develop and debugger) no: i should install also on it to make LOCAL mode workable ?
For now i'd like to: Run Application in the LOCAL Mode and in fact i'm executing it from Xojo in DebugBuild:

#If DebugBuild then


You write in your Wiki:
At this point you can try to RUN this modified project in LOCAL mode, to see that it still works using built-in SQLite engine of Xojo.
So why i'm receiving that error if the App is running in LOCAL Mode and should use the built-in SQLite engine of Xojo ?

On the other side when i'll be on CLIENT mode (hoping to solve first that issue) the example posted creates new Database, but i'd like to use my existing SQLite database that i insert in the VServer in the folder 'databases_sqlite'.
The code in that case i should use is:


if ArchivioInRete = "SI" then
DB.Host = "192.168.188.31"
DB.UserName = "sa"
DB.Password = "sa"
DB.Port = 15532
Try
DB.Connect()
Catch err As DatabaseException
MessageBox ("Errore: " + err.Message)
Return
End Try
DB.databaseName = "NiP.db"
End If


Correct ?
Thanks
Comment
There are no comments made yet.
  1. more than a month ago
  2. as SQLite DB Server
  3. # 3
Ruslan Zasukhin Accepted Answer
Aha,

https://docs.xojo.com/Database.AddRow

it seems this is a new function in Xojo: New in 2019r2

In our example (copied from older Xojo it was as )


// Add a row to the Team table
If Not IsConnected Then
MsgBox("Create the database and create the table first.")
Return False
End If

Dim row As New DatabaseRecord
// ID will be added automatically
row.Column("Name") = name
row.Column("Coach") = coach
row.Column("City") = city
App.DB.InsertRecord("Team", row)

If App.DB.Error Then
AddDataStatusLabel.Text = "DB Error: " + App.DB.ErrorMessage
Return False
End If

Return True


Tomorrow we will check this issue more deeply.
Comment
There are no comments made yet.
  1. more than a month ago
  2. as SQLite DB Server
  3. # 4
Fabrizio Accepted Answer
I'm receiving the same ErrorNumber 427264 when execute, always in LOCAL mode this query:


DB.ExecuteSQL("DELETE FROM Notifiche WHERE ID="+ID)


And also with this query:


var rs as RowSet = DB.SelectSQL("select * from Notifiche where ID="+ID)
rs.EditRow
rs.Column("Notificato").StringValue = EsitoNotifica
rs.SaveRow


Sorry but i don't understand: why if in LOCAL mode Xojo should continue to use the built-in SQLite engine your Valentina plugin should affect that and give us these errors ?
Btw on my MBP so i don't need to install SValentina to make LOCAL mode workable ?
Comment
There are no comments made yet.
  1. more than a month ago
  2. as SQLite DB Server
  3. # 5
Ruslan Zasukhin Accepted Answer
When you changed to VSQliteDatabase you start using OUR copy of SQLite database engine.
As you could see in WIKI pages, we extend API of SqliteDatabase class of Xojo adding e.g. few Ex methods.
So to get the same code for both local and client, developer can use our copy of SQLite.

We have check our Examples, they work, including AddRow()

Maybe you can send us your test project and we check it here?
Comment
There are no comments made yet.
  1. more than a month ago
  2. as SQLite DB Server
  3. # 6
Fabrizio Accepted Answer
Sure, as written in private, send me the email where i can send you the project (and database)
Comment
There are no comments made yet.
  1. more than a month ago
  2. as SQLite DB Server
  3. # 7
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.