Share My Creation iSQLiteLight Three simple SQLite projects

The three projects are portations of the three BA4 SQLiteLight programs to B4i.

These examples are explained in the B4XSQLiteDatabase Booklet.

- iSQLiteLight1
A very simple project with a very simple user interface with following functions:
At the first run the database is empty and the user must add entries.
- Add an entry
- Edit an entry
- Update an entry
- Delete an entry
- Display next and previous entry

- iSQLiteLight2
A simple project with some more functions:
A default database is supplied to allow the use of the filter without the need to add many entries.
- Display the database in a table with following functions:
-- Add display the Edit activity to add a new entry
-- Edit display the Edit activity to edit an entry
-- Filter filter the database
-- Set Filter display the Filter activity to set the filter
- Edit
-- Add / Update / Delete
-- First / Previous / Next / Last
- Filter

The database is very simple with four columns :
- ID
- FirstName
- LastName
- City

- iSQLiteLight3
Same as SQLiteLight2, all functions are the same.
The differences are the database path, database name, table name, columb number, column names, column alias names and column data types are variables instead beeing hard coded.
It allows also to generate a new database by:
- changing in Globals the values of the variables listed above
- in Activity_Create
-- comment this line : 'File.Copy(File.DirAssets, SQLDateBaseName, SQLDataBasePath, SQLDateBaseName)
-- uncomment this line : CreateDataBase

The code has comments and is, I hope, self explanatory.
 

Attachments

  • iSQLiteLight3.jpg
    iSQLiteLight3.jpg
    58.2 KB · Views: 2,274
  • iSQLiteLight1.zip
    5.7 KB · Views: 868
  • iSQLiteLight2.zip
    12.3 KB · Views: 825
  • iSQLiteLight3.zip
    10.5 KB · Views: 876
Last edited:

Beja

Expert
Licensed User
Longtime User
Great Great Great Klaus.. Thank you>>>> :)
 

klaus

Expert
Licensed User
Longtime User
Hello @klaus, did it take long to port?
Well, I haven't measured the time.
It wasn't complicated, but much time was spend to learn B4i related to iOS.
Even the SQLite treatment is a bit different.
It will probably take about half the time for future projects when getting more experience.
You need to get accustomed to the different user interface specific to iOS and the different views.
This link is useful to get an 'iOS feeling'.
To move from B4A to B4i, begin with 'simple' projects to master the differences between the two systems.
 

jo1234

Active Member
Licensed User
Longtime User
Hi Klaus,

could you please add the source code to your post?

thanks a lot!
John
 

ilan

Expert
Licensed User
Longtime User
really nice, i would love to understand how sql works... (have 0 experience with it :( )
 

ilan

Expert
Licensed User
Longtime User
hi klaus, i tried your example (iSQLlight1) and its really great. i started to learn sql now, there i can find anything i need for my app except of one thing.

there is a example how to add new entry, edit, delete only no search for an entry. like i have an entry where i dont know the ID but i know the name of the person in this entry how do i get it??

well i figured it out after few minutes and come up with this.


B4X:
Sub Button1_Click
    Dim whatcolum As String = "Firstname"
    Dim search As String = "ilan"
 
    sqlsearch(whatcolum,search)
End Sub

Sub sqlsearch(tosearch As String, txt As String)
 
    Dim Query As String
    Dim ResultSet1 As ResultSet
 
    Query = "SELECT * FROM persons WHERE " & tosearch & " = ?"
    ResultSet1 = SQL1.ExecQuery2(Query, Array As String (txt))

    If ResultSet1.NextRow = True Then
        lblID.Text = ResultSet1.GetString("ID")
        CurrentIndex = NumberFormat(lblID.Text - 1,1,0)
        txfFirstName.Text = ResultSet1.GetString("FirstName")
        txfLastName.Text = ResultSet1.GetString("LastName")
        txfCity.Text = ResultSet1.GetString("City")
    End If

    ResultSet1.Close                                                                     
End Sub

thank you very much for this example now i can start with my new app (i know how to add, edit, delete and search in sql database):)
 

Beja

Expert
Licensed User
Longtime User
Hi Klaus,
Are these projects available for B4J too. Thanks.
 
Top