If you find yourself working with SQLite and XOJO and would like to try template based “Database-First” approach to XOJO source code generation, then you may want to try myBackSpace.com. The template is hosted by the fantastic folks over at My2ndGeneration.com via their cloud interface.
This could save you some time building those repetitive database access layers in your application and since we generate XOJO source code; it works with all XOJO project types.
myBackSpace.com is 100% free and generates 100% XOJO source code.
k.fldIme =“Some first name”
k.fldKorisnikID = 100 (i don’t Know why it did not autoincriment so i added it manualy for test
k.fldKorisnickoIme =“Login user name”
k.fldKorisnikGUID = app.NewGUID
k.fldLozinka = App.Hash(“password”)
k.fldMail = “mail@mail.com”
k.fldPrezime = “Surname”
k.fldVerificiran = true
Glad you found us and are having some success with myBackSpace. We enjoy building it.
Using your code above as a sample. The following line should not be required when adding new rows. It does not cause an issue if it is there.
k.IsNew = true
The auto increment values are populated by the database engine following the save operation. Try the following in your code.
If k.Save = true Then
MsgBox(“Saved”)
//Now k.fldKorisnikID will be populated with the auto number.
End If
We are in the process of building a sample application that is hosted on GitHub that demonstrates the architecture. Right now it is a Web application, but our plans include tasks to build the sample in each of the XOJO project types.
Please be aware that a For Each loop is not guaranteed to happen in the order of the elements in an array. You should change your examples to For i As Integer = 0 To …Ubound. From the docs:
Your code uses a lot of Mes where Selfs would be more appropriate. It is not wrong to use Me, but Me in Xojo is not meant to be the same as Me in VB and VB Net. From the docs:
If g.Save = True then
MsgBox(“Saved”)
else
msgbox(“Not Saved”)
end if
IS saving
I was doing this with SQLite without autoincrement and with autoincrimet specified in db field creating to see if something is wrong… but the same result, when i add g.fldId = 1 then it Works…
Reading in documentation, when inserting in SQLite db new row, you need to insert with NULL value to work with autoincriment from DB i did not manage to check your generated code if there is maybe a bug that passes some value or something and not null in insert comand
– Describe USERS_IX_GROUP_ID
CREATE INDEX [Users_IX_Group_Id]
ON [Users]
([Group_Id] DESC)
– Describe FKI_USERS_GROUP_ID_USERGROUPS_ID
CREATE TRIGGER [fki_Users_Group_Id_UserGroups_Id] Before Insert ON [Users] BEGIN SELECT RAISE(ROLLBACK, ‘insert on table Users violates foreign key constraint fki_Users_Group_Id_UserGroups_Id’) WHERE NEW.Group_Id IS NOT NULL AND (SELECT Id FROM UserGroups WHERE Id = NEW.Group_Id) IS NULL; END
– Describe FKU_USERS_GROUP_ID_USERGROUPS_ID
CREATE TRIGGER [fku_Users_Group_Id_UserGroups_Id] Before Update ON [Users] BEGIN SELECT RAISE(ROLLBACK, ‘update on table Users violates foreign key constraint fku_Users_Group_Id_UserGroups_Id’) WHERE NEW.Group_Id IS NOT NULL AND (SELECT Id FROM UserGroups WHERE Id = NEW.Group_Id) IS NULL; END
And when i run this in SQLiteman Insert into usergroups values (null, “Test1”, “Test”) it inserts into db and gives it next ID … so i Know autoincrement Works… and DB is ok