B4J Question DButils multicolumn handling

ThRuST

Well-Known Member
Licensed User
Longtime User
I want to use DButils to list multicolumn contents from a SQLite database in a tableview.
However so far I can only list the query into the first column, even though I initialize with mylist = tableview.items to associate the list data with the tableview columns. My db holds 7 columns, so how to work with lists with a 7 column database contents through dbutils? This keeps my busy.

Parts of my code
B4X:
Dim tableView1 As TableView
Dim mylist As List
Private SQL1 As SQL

mylist.Initialize
mylist = tableView1.Items

SQL1.InitializeSQLite("c:\", "test.sqlite", False)

DBUtils.ExecuteTableView(SQL1, "SELECT DocName FROM UserTable", Null, 0, tableView1)
  
    For Each i As String In mylist
    Log(i)
    Next

Any clues are very appreciated, thanks.
 

stevel05

Expert
Licensed User
Longtime User
You are specifying only one column to select:

B4X:
"SELECT DocName FROM UserTable"

So only data in the column Docname will be returned.

Try

B4X:
"SELECT * FROM UserTable"
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Try
"SELECT * FROM UserTable"

dbutils.PNG


Thanks Steve, that worked :) The image shows my SQLite database which I've used with a prototype code snippets tool that I wrote 3 years ago in C sharp, so I am porting that application to B4J. It does not look so good and have to be tweaked, but it's a milestone that I've come this far with my work. Actually it helped me to study your code earlier today. I'm impressed by how well you've understood B4J and how you organize your code in code modules. Nice and tidy code, well done.
What's your suggestion when to use ExecuteList, ExecuteMap and ExecuteMemoryTable? I've noticed you used the last one in your project.
My B4j project progresses well, and I usually separate my examples untill I cover them enough to implement the functionality in my project. B4J is great fun and I am green of envy from studying your code :D
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
btw my for each loop return this

Waiting for debugger to connect...
Program started.
[Ljava.lang.String;@3615810a
[Ljava.lang.String;@1243e327
[Ljava.lang.String;@40e2bd8b
[Ljava.lang.String;@501e4209
[Ljava.lang.String;@4a9984d1
[Ljava.lang.String;@47ce1c7e
[Ljava.lang.String;@1215efe9
[Ljava.lang.String;@30b9e9a8
[Ljava.lang.String;@36004c62
[Ljava.lang.String;@19a9b30
[Ljava.lang.String;@3c4d564d
[Ljava.lang.String;@43c61cc5
[Ljava.lang.String;@77113b83
[Ljava.lang.String;@22876d4a
[Ljava.lang.String;@74aeb869
[Ljava.lang.String;@77da20d
[Ljava.lang.String;@794e5c42
[Ljava.lang.String;@603a831c
[Ljava.lang.String;@61560282
[Ljava.lang.String;@b51b96f
[Ljava.lang.String;@f6480b
[Ljava.lang.String;@34e0196a
[Ljava.lang.String;@65f35f66
[Ljava.lang.String;@636f1876
[Ljava.lang.String;@51eba200
[Ljava.lang.String;@6574da1e
[Ljava.lang.String;@1a03b1b9
[Ljava.lang.String;@134b627
[Ljava.lang.String;@d43ffa3
[Ljava.lang.String;@4e24703f
[Ljava.lang.String;@49ad9e3b
[Ljava.lang.String;@6d0c8ca7
[Ljava.lang.String;@7fa0c842
[Ljava.lang.String;@12e8fa01
[Ljava.lang.String;@3711e221
[Ljava.lang.String;@3ef129d0
[Ljava.lang.String;@47ea1494
[Ljava.lang.String;@1287c69a
[Ljava.lang.String;@2abf3e01
[Ljava.lang.String;@1db73d2f
[Ljava.lang.String;@a6ec4b9
[Ljava.lang.String;@26717078
[Ljava.lang.String;@756d0d81
[Ljava.lang.String;@51971846
[Ljava.lang.String;@2d2045c1
[Ljava.lang.String;@7f02ad
[Ljava.lang.String;@1d631626
[Ljava.lang.String;@745f78e4
[Ljava.lang.String;@5b7e25e3
[Ljava.lang.String;@236c3e4b
[Ljava.lang.String;@263bde26
[Ljava.lang.String;@29ac1a5d
[Ljava.lang.String;@3d773b6
[Ljava.lang.String;@418b8be1
[Ljava.lang.String;@39b9b718
[Ljava.lang.String;@708e3c80
[Ljava.lang.String;@487cbbe4
[Ljava.lang.String;@5535f589
[Ljava.lang.String;@21c08940
[Ljava.lang.String;@20abcbc4
[Ljava.lang.String;@d25e7ae
[Ljava.lang.String;@7746d23e
[Ljava.lang.String;@5269df1f
[Ljava.lang.String;@2c62db7d
[Ljava.lang.String;@ed851c8
[Ljava.lang.String;@4f4eb50f
[Ljava.lang.String;@53431ade
[Ljava.lang.String;@69c09af8
[Ljava.lang.String;@25dad019
[Ljava.lang.String;@1f86ff60
[Ljava.lang.String;@545893a4
[Ljava.lang.String;@3922c48d
[Ljava.lang.String;@4a8b91a8
[Ljava.lang.String;@625e1a66
[Ljava.lang.String;@728b703a
[Ljava.lang.String;@5d22c44a
[Ljava.lang.String;@4b321897
[Ljava.lang.String;@59adb6bd
[Ljava.lang.String;@700e1712
[Ljava.lang.String;@3b459dcd
[Ljava.lang.String;@6068dc92
[Ljava.lang.String;@5444967c
[Ljava.lang.String;@5472ad61
[Ljava.lang.String;@434ee9d7
[Ljava.lang.String;@65e42160
[Ljava.lang.String;@1563acd6
[Ljava.lang.String;@543b12be
[Ljava.lang.String;@600f49bf
[Ljava.lang.String;@24a48bff
[Ljava.lang.String;@2ca996a1
[Ljava.lang.String;@208bdf68
[Ljava.lang.String;@3ad33877
[Ljava.lang.String;@3a28a7a1
[Ljava.lang.String;@5a5432db
[Ljava.lang.String;@24dac666
[Ljava.lang.String;@7e9520a
[Ljava.lang.String;@7803e8f9
[Ljava.lang.String;@3badfc8
[Ljava.lang.String;@71a1d02f
[Ljava.lang.String;@3c95a513
[Ljava.lang.String;@5b36c658
[Ljava.lang.String;@e270669
[Ljava.lang.String;@71789f2a
[Ljava.lang.String;@6054012b
[Ljava.lang.String;@d3d0f7f
[Ljava.lang.String;@3b9f54ff
[Ljava.lang.String;@e2b0d69
[Ljava.lang.String;@4eb618de
[Ljava.lang.String;@2b15a080
[Ljava.lang.String;@6a6c21b1
[Ljava.lang.String;@3cfa39d0
[Ljava.lang.String;@4274a679
[Ljava.lang.String;@44630f17
[Ljava.lang.String;@4f89df83
[Ljava.lang.String;@22505b1b
[Ljava.lang.String;@45706646
[Ljava.lang.String;@19b7d248
[Ljava.lang.String;@18c3633a
[Ljava.lang.String;@386b6bba
[Ljava.lang.String;@7e6f78a7
[Ljava.lang.String;@59edc0b0
[Ljava.lang.String;@5a34b204
[Ljava.lang.String;@39612443
[Ljava.lang.String;@3cced988
[Ljava.lang.String;@b9166e1
[Ljava.lang.String;@744a5105
[Ljava.lang.String;@44b920f3
[Ljava.lang.String;@e71a375
[Ljava.lang.String;@e576a34
[Ljava.lang.String;@28b3c082
[Ljava.lang.String;@2500d3df
[Ljava.lang.String;@26e9a601
[Ljava.lang.String;@13da6e22
[Ljava.lang.String;@255b0b0b
[Ljava.lang.String;@666ba54
[Ljava.lang.String;@6dd4dd37
[Ljava.lang.String;@2dbf15d1
[Ljava.lang.String;@5041403e
[Ljava.lang.String;@6346f478
[Ljava.lang.String;@2830a042
[Ljava.lang.String;@7df42908
[Ljava.lang.String;@276ec638
[Ljava.lang.String;@73df1399
[Ljava.lang.String;@5e409f10
[Ljava.lang.String;@2a051b9
[Ljava.lang.String;@53ae18d3
[Ljava.lang.String;@58669ae4
[Ljava.lang.String;@20436e7
[Ljava.lang.String;@2a99287
[Ljava.lang.String;@21627a81
[Ljava.lang.String;@4dbf65f3
[Ljava.lang.String;@6eafc1ad
[Ljava.lang.String;@20dc5b55
[Ljava.lang.String;@12d89bbd
[Ljava.lang.String;@247ee4e8
[Ljava.lang.String;@34ccfb63
[Ljava.lang.String;@7608185c
[Ljava.lang.String;@205b6053
[Ljava.lang.String;@73519914
[Ljava.lang.String;@209563fe
[Ljava.lang.String;@16694548
[Ljava.lang.String;@6dcbf62e
[Ljava.lang.String;@12ad5bba
[Ljava.lang.String;@192c5082
[Ljava.lang.String;@45b305ea
[Ljava.lang.String;@77fbf1f4
[Ljava.lang.String;@f73043a
[Ljava.lang.String;@7420fd16
[Ljava.lang.String;@29613a2d
[Ljava.lang.String;@1bd0aa4
[Ljava.lang.String;@16f88c7d
[Ljava.lang.String;@65430bf9
[Ljava.lang.String;@4553e52e
[Ljava.lang.String;@2c523f0a
[Ljava.lang.String;@7e1bc599
[Ljava.lang.String;@37a0560
[Ljava.lang.String;@595afab4
[Ljava.lang.String;@644d24fa
[Ljava.lang.String;@445a12e7
[Ljava.lang.String;@17584e09
[Ljava.lang.String;@19d9990c
[Ljava.lang.String;@14be0439
[Ljava.lang.String;@e7e163
[Ljava.lang.String;@551adf70
[Ljava.lang.String;@de3d26
[Ljava.lang.String;@64a57ec8
[Ljava.lang.String;@5bf667c6
[Ljava.lang.String;@5894c297
[Ljava.lang.String;@29d2f3ae
[Ljava.lang.String;@66ce9b62
[Ljava.lang.String;@e6e082a
[Ljava.lang.String;@7010f30a
[Ljava.lang.String;@4ee12125
[Ljava.lang.String;@5ce6b610
[Ljava.lang.String;@22b7cafe
[Ljava.lang.String;@5548e501
[Ljava.lang.String;@12e70e84
[Ljava.lang.String;@7bd86cfe
[Ljava.lang.String;@67a4b941
[Ljava.lang.String;@75d62859
[Ljava.lang.String;@5f6f8b49
[Ljava.lang.String;@6768b3c6
[Ljava.lang.String;@25c460db
[Ljava.lang.String;@611400da
[Ljava.lang.String;@4282ea72
[Ljava.lang.String;@60569767
[Ljava.lang.String;@6612e10e
[Ljava.lang.String;@27413fc6
[Ljava.lang.String;@72c58026
[Ljava.lang.String;@26fcdcb6
[Ljava.lang.String;@579753f6
[Ljava.lang.String;@7986e9cd
[Ljava.lang.String;@279c826b
[Ljava.lang.String;@6745f342
[Ljava.lang.String;@aa004bf
[Ljava.lang.String;@44a64ca7
[Ljava.lang.String;@7ea0182
[Ljava.lang.String;@4ffd3dde
[Ljava.lang.String;@45725d62
[Ljava.lang.String;@3347f21f
[Ljava.lang.String;@64f603e4
[Ljava.lang.String;@42c3d169
[Ljava.lang.String;@150d0d1e
[Ljava.lang.String;@19d6d2aa
[Ljava.lang.String;@4deb1b57
[Ljava.lang.String;@11ffd31a
[Ljava.lang.String;@6ce759c6
[Ljava.lang.String;@430b8572
[Ljava.lang.String;@56af1fe7
[Ljava.lang.String;@39a7612b
[Ljava.lang.String;@6f5836b0
[Ljava.lang.String;@70670e3c
[Ljava.lang.String;@5e9977f0
[Ljava.lang.String;@5cb5fb31
[Ljava.lang.String;@72f6aba1
[Ljava.lang.String;@3aa84d2d
[Ljava.lang.String;@2f9b8b7f
[Ljava.lang.String;@5c0481ce
[Ljava.lang.String;@1be8824c
[Ljava.lang.String;@63d16539
[Ljava.lang.String;@1062ca4f
[Ljava.lang.String;@6810237c
[Ljava.lang.String;@37b526d0
[Ljava.lang.String;@5f2565b2
[Ljava.lang.String;@5993fcab
[Ljava.lang.String;@30f13f26
[Ljava.lang.String;@2e6c1c4e
[Ljava.lang.String;@5a90e4c4
[Ljava.lang.String;@1c202d99
[Ljava.lang.String;@25912934
[Ljava.lang.String;@6b51dfa4
[Ljava.lang.String;@36bab0ce
[Ljava.lang.String;@2beb0f65
[Ljava.lang.String;@71f4ba5
[Ljava.lang.String;@62d6081d
[Ljava.lang.String;@189e849
[Ljava.lang.String;@72ea4f3a
[Ljava.lang.String;@fd560a1
[Ljava.lang.String;@5d1117a6
[Ljava.lang.String;@131477ed
[Ljava.lang.String;@33a7692a
[Ljava.lang.String;@17d3c797
[Ljava.lang.String;@42aa4eec
[Ljava.lang.String;@7231e24b
[Ljava.lang.String;@7a572b1e
[Ljava.lang.String;@7331b4bc
[Ljava.lang.String;@637c5918
[Ljava.lang.String;@1e22cc86
[Ljava.lang.String;@5dee1b87
[Ljava.lang.String;@2304c0d2
[Ljava.lang.String;@2231f933
[Ljava.lang.String;@2a7f470f
[Ljava.lang.String;@7e053e4
[Ljava.lang.String;@267119a
[Ljava.lang.String;@2f328884
[Ljava.lang.String;@7fa5e552
[Ljava.lang.String;@7a5fe631
[Ljava.lang.String;@408ed321
[Ljava.lang.String;@7bc3151c
[Ljava.lang.String;@2b1cf043
[Ljava.lang.String;@2e77e57f
[Ljava.lang.String;@18d63c4b
[Ljava.lang.String;@7b5ea1b8
[Ljava.lang.String;@378cc878
[Ljava.lang.String;@26c19feb
[Ljava.lang.String;@f5cdb1c
[Ljava.lang.String;@101e82e
[Ljava.lang.String;@501f2f7e
[Ljava.lang.String;@7a8bcc51
[Ljava.lang.String;@13e67c27
[Ljava.lang.String;@1da8b6ed
[Ljava.lang.String;@34e51ef9
[Ljava.lang.String;@1028a570
[Ljava.lang.String;@308ff416
[Ljava.lang.String;@68483334
[Ljava.lang.String;@74c6ea12
[Ljava.lang.String;@2110c2df
[Ljava.lang.String;@6e70bdaf
[Ljava.lang.String;@4708e2c6
[Ljava.lang.String;@4dd064f
[Ljava.lang.String;@23fc3a31
[Ljava.lang.String;@480a6624
[Ljava.lang.String;@4814a331
[Ljava.lang.String;@24173b02
[Ljava.lang.String;@66f8b003
[Ljava.lang.String;@7dd8c1be
[Ljava.lang.String;@1038e81f
[Ljava.lang.String;@dea1e31
[Ljava.lang.String;@2e31df27
[Ljava.lang.String;@155f3e6e
[Ljava.lang.String;@427044ca
[Ljava.lang.String;@1fb6d123
[Ljava.lang.String;@3fdefd15
[Ljava.lang.String;@531e08ce
[Ljava.lang.String;@13085073
[Ljava.lang.String;@3a9eb4f8
[Ljava.lang.String;@72e0d0eb
[Ljava.lang.String;@519bfe01
[Ljava.lang.String;@c1b789
[Ljava.lang.String;@4f37ea1d
[Ljava.lang.String;@3b240c98
[Ljava.lang.String;@35c1960b
[Ljava.lang.String;@383102c5
[Ljava.lang.String;@48a660dc
[Ljava.lang.String;@53fdf59c
[Ljava.lang.String;@6a355026
[Ljava.lang.String;@5aa2508f
[Ljava.lang.String;@21f96b87
[Ljava.lang.String;@1d942b31
[Ljava.lang.String;@5de0fcc5
[Ljava.lang.String;@150ee9de
[Ljava.lang.String;@7f411dab
[Ljava.lang.String;@43306cd1
[Ljava.lang.String;@19ecb6a6
[Ljava.lang.String;@7bcefc5c
[Ljava.lang.String;@c950acb
[Ljava.lang.String;@4c03b96c
[Ljava.lang.String;@30a67fcc
[Ljava.lang.String;@3c064998
[Ljava.lang.String;@1861cf81
[Ljava.lang.String;@4978dd38
[Ljava.lang.String;@4a2383c4
[Ljava.lang.String;@44e75991
[Ljava.lang.String;@52ec8b4b
[Ljava.lang.String;@5d720d33
[Ljava.lang.String;@b9998fa
[Ljava.lang.String;@75cc73c9
[Ljava.lang.String;@434c08e8
[Ljava.lang.String;@e9a9e27
[Ljava.lang.String;@49838946
[Ljava.lang.String;@5f47e984
[Ljava.lang.String;@7cefb1cc
[Ljava.lang.String;@265e73d0
[Ljava.lang.String;@73c217e4
[Ljava.lang.String;@1329cbd1
[Ljava.lang.String;@124979a9
[Ljava.lang.String;@47dc48c3
[Ljava.lang.String;@24420aeb
[Ljava.lang.String;@79682af1
[Ljava.lang.String;@20b58044
[Ljava.lang.String;@58a5ec1
[Ljava.lang.String;@312b19c9
[Ljava.lang.String;@9ac92bf
[Ljava.lang.String;@517846e
[Ljava.lang.String;@523cae5b
[Ljava.lang.String;@3b301084
[Ljava.lang.String;@56645437
[Ljava.lang.String;@6fe98e61
[Ljava.lang.String;@5810bbb1
[Ljava.lang.String;@639f2407
[Ljava.lang.String;@17ae11af
[Ljava.lang.String;@34170fbd
[Ljava.lang.String;@6987f7bd
[Ljava.lang.String;@73225996
[Ljava.lang.String;@14661d34
[Ljava.lang.String;@188092e2
[Ljava.lang.String;@4eeca450
[Ljava.lang.String;@2f63baf2
[Ljava.lang.String;@bc89d97
[Ljava.lang.String;@1743198e
[Ljava.lang.String;@3c26f112
[Ljava.lang.String;@e20784e
[Ljava.lang.String;@41cb7838
[Ljava.lang.String;@4e4b86e6
[Ljava.lang.String;@456e505c
[Ljava.lang.String;@4881b2b7
[Ljava.lang.String;@52110927
[Ljava.lang.String;@40ffd935
[Ljava.lang.String;@77248dc6
[Ljava.lang.String;@32759d9f
[Ljava.lang.String;@6877f2c7
[Ljava.lang.String;@56ffb88d
[Ljava.lang.String;@5e65529
[Ljava.lang.String;@1be1b96f
[Ljava.lang.String;@4cd7911e
[Ljava.lang.String;@67c763d9
[Ljava.lang.String;@503f2d15
[Ljava.lang.String;@4603ccbc
[Ljava.lang.String;@362cfa03
[Ljava.lang.String;@6a298eb4
[Ljava.lang.String;@43d74161
[Ljava.lang.String;@1be9038b
[Ljava.lang.String;@4a441e17
[Ljava.lang.String;@6cbe65c5
[Ljava.lang.String;@159bed7a
[Ljava.lang.String;@463d4119
[Ljava.lang.String;@2ce35b6f
[Ljava.lang.String;@336c837b
[Ljava.lang.String;@79564851
[Ljava.lang.String;@55cfebeb
[Ljava.lang.String;@63c1fa1e
[Ljava.lang.String;@34e1da46
[Ljava.lang.String;@7fbe084b
[Ljava.lang.String;@550424e4
[Ljava.lang.String;@39793550
[Ljava.lang.String;@370ebd3
[Ljava.lang.String;@c0347a6
[Ljava.lang.String;@785471c6
[Ljava.lang.String;@8770829
[Ljava.lang.String;@cdd5487
[Ljava.lang.String;@1a750ccd
[Ljava.lang.String;@41f49404
[Ljava.lang.String;@7172ea53
[Ljava.lang.String;@176de196
[Ljava.lang.String;@25cc84d2
[Ljava.lang.String;@407d60db
[Ljava.lang.String;@263b2af5
[Ljava.lang.String;@5ea20ef5
[Ljava.lang.String;@1f09fbe7
[Ljava.lang.String;@34593b65
[Ljava.lang.String;@4b4ad399
[Ljava.lang.String;@5d1a9a3
[Ljava.lang.String;@5557bc3d
[Ljava.lang.String;@282827e1
[Ljava.lang.String;@35e3ff66
[Ljava.lang.String;@3df7c4c8
[Ljava.lang.String;@55a9211f
[Ljava.lang.String;@3c570364
[Ljava.lang.String;@16e5d347
[Ljava.lang.String;@15b794d7
[Ljava.lang.String;@98aeea7
[Ljava.lang.String;@d4290d1
[Ljava.lang.String;@358505d5
[Ljava.lang.String;@1c3d2e9e
[Ljava.lang.String;@421c0468
[Ljava.lang.String;@5bc1c0e2
[Ljava.lang.String;@46f7dde2
[Ljava.lang.String;@334b427c
[Ljava.lang.String;@11562f39
[Ljava.lang.String;@44452b21
[Ljava.lang.String;@3ca5f686
[Ljava.lang.String;@55141bcc
[Ljava.lang.String;@751bd9b0
[Ljava.lang.String;@186ae811
[Ljava.lang.String;@be83c5c
[Ljava.lang.String;@7ed79c96
[Ljava.lang.String;@55aa1ca5
[Ljava.lang.String;@1acf4c61
[Ljava.lang.String;@500f89b8
[Ljava.lang.String;@12fe9c03
[Ljava.lang.String;@1734f5cd
[Ljava.lang.String;@77781f0e
[Ljava.lang.String;@5b160a10
[Ljava.lang.String;@3d6e8bf5
[Ljava.lang.String;@d449b08
[Ljava.lang.String;@3af375c1
[Ljava.lang.String;@51debe05
[Ljava.lang.String;@1826a6e8
[Ljava.lang.String;@3193f23f
[Ljava.lang.String;@106fc4b1
[Ljava.lang.String;@34e57e2f
[Ljava.lang.String;@19599fbd
[Ljava.lang.String;@377594a3
[Ljava.lang.String;@595194b0
[Ljava.lang.String;@46da8db3
[Ljava.lang.String;@13ab46a2
[Ljava.lang.String;@8e018f8
[Ljava.lang.String;@5dc1e940
[Ljava.lang.String;@4f64405e
[Ljava.lang.String;@6b38146
[Ljava.lang.String;@e1c7eb0
[Ljava.lang.String;@5cc50dda
[Ljava.lang.String;@31cec0ac
[Ljava.lang.String;@2bedde62
[Ljava.lang.String;@4669cc51
[Ljava.lang.String;@3236b29b
[Ljava.lang.String;@753acfd1
[Ljava.lang.String;@306111da
[Ljava.lang.String;@386258c3
[Ljava.lang.String;@3fc7973e

Any suggestion how to read each column in a proper (readable) way? :confused:
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Thanks for the nice comments, I like to try and keep my code tidy. It helps others understand it and me maintain it. On the forums a year may go past from the time code is shared to questions being asked, so it helps if it's easily readable.

I've been using B4x in one form or another for almost 6 years, so I've been able to learn each piece that has been added in an orderly fashion. I do feel for people starting out now as the environments are (by necessity) large, and there is a lot to learn.

When to use each method depends on what you want to do with the data. Most of the methods return one record. ExecuteTableView and ExecuteMemoryTable return multiple records. If the data were ready to present straight from the table, I'd use ExecuteTableView, but more often that note you want to do something different with it, so I'd use ExecuteMemoryTable.

To answer your second question the [Ljava.lang.String@..... is a pointer to a string array. I guess it's from ExecuteMemoryTable so each element in the list is an array and each element of the array is a column in a record, so it would be.

B4X:
For Each arr() as String in L
  Log($"${arr(0)} ${arr(1)} ${arr(2)}"$) 'etc
Next

Hope it helps
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
For Each arr() as String in mylist
Log($"${arr(0)} ${arr(1)} ${arr(2)}"$) ' etc
Next

Thanks, I've only been learning B4J for about 3 month, however I've been using B4A for more than 2 years so that makes it easier to work with B4i and B4J.
B4X is easy to pick up after nearly 15 years with VB6/VB.NET.

* Do you mind explaining the for each solution because it will help learning what's happening.
* How would you store each db column data in an array of lists instead of the log? (which could be useful to keep the db contents in memory).

Below is what the readable output looks like. (it's some of my personal stuff I've covered if anyone is interested, this is what my project is all about)

Waiting for debugger to connect...
Program started.
26 Csharp Add text to an image
27 Csharp Draw LinearGradientBrush
28 Csharp Draw Multiple Colored LinearGradientBrush
29 Csharp Draw Free drawing in panel
32 Csharp Files - List files in a directory
33 Csharp Files - Get a list of folders
36 Csharp Folders - Create a new folder
37 Csharp Folders - Move a folder
41 Csharp MessageBox Default
42 Csharp Folders - Get a folders creation date
43 Csharp Draw - Free drawing source code
44 Csharp Math - Return value of PI
45 Csharp Math - Round a value
46 Csharp Randomize ByteArray
47 Csharp Randomize Chars
48 Csharp Random number
50 Csharp SQLite - Basic reading from database
51 Csharp String - Remove text from a string
52 Csharp String - Replace
53 Csharp String - Split a string
54 Csharp String - ToCharArray
55 Csharp String - IndexOf
56 Csharp String - Trim
65 Java Draw - Add circle
66 Java Draw - Add square
67 Java Init - Array int
69 Java Init - Array int Twodimensional
71 Java JButton Click
72 Java Class - Main
73 Java Class - New
74 Java Convert - int to Integer
75 Java Convert - Integer to int
76 Java For next loop - Enhanced
77 Java For next loop - Reversed
79 Java Init - Array int 2
82 Java Form - Make form fullscreen
83 Java MessageBox - Error notification
84 Java MessageBox - Info
85 Java MessageBox - Inputbox
86 Java MessageBox - Standard
87 Java MessageBox - Yes No Cancel
88 Java MessageBox - Yes No Cancel
89 Java Random Number
90 Java File - Save text to file
92 Java Switch
93 Java While
94 Java Form - Basic form
96 Java Init - Array String
101 Csharp Init - int
102 Csharp Init - string
104 Csharp Init - Remark Standard
105 Csharp Init - Remark Enhanced
106 Csharp For next loop - Default
107 Java For next loop - Default
108 Csharp Hotkey without form focus
125 Csharp ToolStripItem - Key
132 Java SQLite Retrieve data
133 Java SQLite Insert
134 Java SQLite Update
135 Java SQLite Delete
136 Java SQLite Create a Table
137 Java SQLite Open connection
142 Java Windowbuilder GUI Plugin
146 Java JLabel Image
147 Csharp ColorDialog - Pick a Color
150 Java Timer - Through JButton
152 Java Timer - Task
153 Unity Compile code to only work in Unity editor
158 Csharp Drives - List available drives (Combobox)
159 Csharp Drives - List available drives (Listview)
160 Csharp Listview - Images from URLs
162 Csharp Listview - Imagelist
163 Csharp ContextMenuStrip - Selection
164 Csharp ToolStripMenuItem - Font
165 Unity Movement in 3D (Basic example)
166 Unity 3D Commands #If
167 Unity 3D Commands #region
168 Unity 3D Commands ~
169 Unity 3D Commands Attribute
170 Unity 3D Commands checked
171 Unity 3D Commands class
172 Unity 3D Commands Constructor - ctor
173 Unity 3D Commands WriteLine
174 Unity 3D Commands Do loop
175 Unity 3D Commands Else
176 Unity 3D Commands enum
177 Unity 3D Commands EventArgs
178 Unity 3D Commands Exception
179 Unity 3D Commands for next loop
180 Unity 3D Commands for next loop reversed
181 Unity 3D Commands if
182 Unity 3D Commands indexer
183 Unity 3D Commands interface
184 Unity 3D Commands lock
185 Unity 3D Commands mn
186 Unity 3D Commands mx
187 Unity 3D Commands namespace
189 Unity 3D Commands prop
190 Unity 3D Commands propg
191 Unity 3D Commands Class Main
192 Unity 3D Commands struct
193 Unity 3D Commands switch
194 Unity 3D Commands svm
195 Unity 3D Commands try
196 Unity 3D Commands try finally
197 Unity 3D Commands unchecked
198 Unity 3D Commands unsafe
199 Unity 3D Commands while
200 Unity MouseButtons
201 Unity Transform
202 Unity Random
203 Unity Object Instantiate
204 Unity Input Touches
205 Unity GUI Color
206 Unity GUI Skin
207 Unity GUI Box
208 Unity GUI Button
209 Unity GUI DragWindow
211 Unity GUI HorizontalScrollbar
213 Unity GUI Label
214 Unity Array
215 Unity Files - Get filename
216 Unity Files - Get directory
217 Unity String
218 Unity Unity Online Documentation
220 Unity SQLite (Javascript)
221 Unity Multitouch Input
223 Unity Patrolpoint
224 Unity Network - Get list of running servers
226 Unity Mouse cursor Show/Hide
227 Unity Camera - Follow (3rd person view)
228 Unity Spawn object - From previous loaded scenes
229 Unity Extensions
230 Unity Singletons
231 Unity Enum - For cleaner code
232 Unity serializable classes
233 Unity Project structure
234 Unity Development Tips
235 Java FX Basic Form with a button
237 Unity File - Save Textfile
238 Unity File - Load Textfile
239 MT4j Class - Main Class
240 MT4j Class - ExampleScene
241 MT4j TextField
242 MT4j Background color
247 Unity Joystick - FloatingPlayer2DController Class
248 Unity Joystick - Circle movement
249 MT4j Rectangle - Draggable and tap changes random color
250 MT4j Rectangle - Longclick changes random color
251 MT4j Gesture - Draw rectangle or circle
252 Java MySQL Basic Connection (JDBC)
253 Java SQL Server 2012 - Basic connection
255 Unity Mouselook Class
256 Java MySQL Insert
259 Java MySQL Insert with parameters
260 Java MySQL Delete by userID
261 Java MySQL Delete by username
262 Java MySQL Update with parameters
267 Basic4Android Folder - Create
268 Basic4Android Variable - String
269 Basic4Android Variable - Int
270 Basic4Android Keyboard - IME
271 Basic4Android ScrollView
272 Basic4Android Image - Add text to an image
273 Basic4Android MessageBox - MsgBox2 Select Case
274 Basic4Android Image - Load image
277 Basic4Android FTP - Remove folder
279 Basic4Android FTP - DownloadProgress
280 Basic4Android Timer
286 Basic4Android FTP - Download File
302 Basic4Android Image - Set background image
303 Basic4Android Activity - Load
304 Basic4Android Variables - Dim Int Array
305 Basic4Android TouchImageView
312 Basic4Android FTP - Create folder
313 Basic4Android FTP - Delete File
314 Basic4Android Array - Single dimensioned array
315 Basic4Android FTP - UploadProgress
316 Basic4Android FTP - UploadCompleted
317 Basic4Android FTP - Login to server
318 Basic4Android Variable - Declare variable
319 Basic4Android Loops - Do Loop
320 Basic4Android Loops - For Next
321 Basic4Android If - Single
322 Basic4Android If - Multiline
323 Basic4Android MessageBox - Standard
324 Basic4Android MessageBox - MsgBox2 with image
325 Basic4Android Format - Numbers
326 Basic4Android Sender
327 Basic4Android StartServiceAt
328 Basic4Android StopService
329 Basic4Android Loops - While
330 Basic4Android Randomize - Number
331 Basic4Android String - Check lenght
332 Basic4Android Date - DateTime
333 Basic4Android Intent - YouTube
334 Basic4Android Intent - Visit webpage
335 Basic4Android Randomize - Formatted number
336 Basic4Android Variable - Type
337 Basic4Android MediaPlayer
338 Basic4Android Select Case
339 Basic4Android Notification
340 Basic4Android String - Replace
341 Basic4Android EditText - Allow only numbers
343 Basic4Android KeyPress - Disable Back Button
344 Basic4Android Touch - Action
345 Basic4Android FTP_auto - Upload File
346 Basic4Android FTP_auto - Folder exist
347 Basic4Android FTP_auto - Download File
348 Basic4Android FTP_auto - File exist
350 Basic4Android Folder - Create internal
352 Basic4Android Storage
354 Basic4Android OkHttp - Download file
356 Basic4Android Database - MySQL interaction
359 Java FX Class - MainController
361 Java FX Basic Form - Eclipse
364 Csharp TreeView - Basic example
365 Csharp TreeView - Remove Selections
369 Csharp TreeView - Search TreeView
370 Csharp TreeView - Complete solution
371 Csharp Cursor - Mouse cursor icon
372 Csharp TreeView - File system directory structure
373 Java FX Group toggle buttons
374 Basic4iOS Hello World example
375 Java FX Basic Form - Load FXML
376 Java FX CSS - Basic CSS file
377 Java FX CSS - Labels with dropshadow effect
378 Java FX Background image
379 Java FX Randomize a number (RND)
380 Java FX Get button text
381 Java FX Login form
382 Java FX ComboBox Add using array
384 Csharp Special Characters
385 Csharp Listbox - get text of item
387 Basic4Android Send email
388 Basic4iOS Touch
390 Basic4iOS Timer
392 Basic4iOS Files
393 Basic4iOS Subfolders
394 Basic4iOS List
396 Basic4iOS MsgBox
397 Basic4iOS Font size
399 Basic4iOS Storage
400 Basic4iOS MsgBox 2
402 Csharp Custom Font
404 Csharp Custom Font Example
406 Csharp Listview - Checks if all is checked
407 Java FX ListView Loop through
409 Java FX ListView Init
410 Java FX Resize form disabled
411 Java FX Mouse cursor
413 Java FX Image code in FXML
414 Csharp Listview - Get only checked selections
416 Csharp Dialogresult yes / no
417 Csharp Keydown
418 Csharp Arrow keys #1
419 Csharp NotifyIcon
420 Csharp ListView Remove selections
421 Csharp Registry - Save
424 Csharp Registry - Load
426 Csharp Instance is allready running
427 Java FX Timer examples
428 Csharp Files - Browse to a file
429 Csharp SQLite Read from DB with parameters
431 Csharp SQLite Read from DB with parameters (Filter)
432 Csharp ListViewColumnSorter.cs
433 Csharp SQLite Read two records
435 Csharp ComboBox Save Categories
436 Csharp ComboBox Load Categories
438 C++ FirstProgram.cpp
439 Csharp ListView Search and highlight (Keydown Event)
442 Csharp Files - Read all files in a folder
443 Basic4iOS Prevent app for running in the background
444 Basic4iOS iOS app lifecycle
445 Basic4iOS Call a phone number
446 Basic4iOS Send email
447 Basic4iOS Flashlight
449 Basic4iOS Inline Objective C code
450 Basic4iOS SubString
451 Basic4iOS SubString2
452 Basic4Android Vibrate phone
453 Basic4Android Uninstall an app
454 Basic4iOS Files - Read from txt file
456 Basic4iOS Files - File exists
457 Basic4iOS Files - Copy a file
458 Basic4iOS Randomize number
459 C++/CLI Class - Getter Setter
460 Windows Phone Label (TextBlock)
461 Windows Phone Send email (non silverlight)
463 Basic4iOS Files - iOS files and folders
464 Basic4iOS Try catch
465 Basic4iOS Files - Load textfile
466 Basic4iOS Files - Save textfile
467 Basic4iOS FTP- tmFTP basics
468 Basic4iOS Examples - Email application
469 Basic4iOS ToastMessageShow
470 Basic4iOS Activity - Load
471 Basic4iOS Keyboard - Close
473 Basic4iOS Send email basic
474 Basic4iOS FTP commands
475 Basic4iOS FTP - Upload file
476 Csharp FTP - List files
477 Csharp FTP - Rebex
480 Csharp Files - Delete all files in folder
483 Csharp FTP - Delete directory (Rebex)
484 Csharp FTP - Download all files in a folder (Rebex)
485 Basic4iOS ProgressDialogShow
486 Basic4iOS Examples - PDF reader
487 Basic4Android EditText SelectionStart
490 Basic4Android Copy panel to imageView‏ (Screenshot)
493 Basic4Android Copy panel to imageView‏ V2 (Screenshot)
494 Basic4iOS Copy panel to imageView‏ (Screenshot)
495 PHP Files - Create textfile
497 PHP Folder - Create folder
499 PHP Folder - Remove empty directory
501 PHP Files - Delete a file
502 PHP Files - Rename a file or directory
503 PHP Files - Move uploaded file
505 PHP Files - Opens a file or URL
507 PHP Files - Copy a file
508 PHP Files - Closes an open file
510 PHP Variables - int
511 PHP HTML body
512 PHP FTP - Download a file
513 PHP FTP - Open a connection
514 PHP FTP - Close a connection
515 PHP FTP - Change directory
516 Csharp MySQL - Connection string (IP)
519 PHP Pass variables through URL
521 PHP Variables - String
522 Basic4Java Files - Save textfile
523 Basic4Java Files - Load textfile
525 Basic4Java Files Description
526 PHP mySQL Connection string (Default)
527 Basic4Android Files - Browse
528 Basic4Android Files - Copy file
529 Basic4Android Files - File exists
530 Basic4Android Files - Last modified
531 Basic4Android Files - Load
532 Basic4Android Files - Load Textfile (ReadString)
533 Basic4Android Files - Pick a file
534 Basic4Android Files - Save
536 Basic4Android Files - Write textfile
537 Basic4Android Files - Save Textfile (WriteString)
539 Basic4Android FTP - Upload File
540 Csharp Split string (Regex)
541 Csharp Split string (one listview column)
542 Csharp Files - Save file
543 Csharp Files - Load file
544 Csharp Contextmenu MouseWheel scroll
545 Csharp Notifyicon (Leftclick enabled contextmenu)
546 Csharp Registry - Autostart application
547 Csharp Process Start
548 Csharp Folders - Browse to a folder
549 Csharp Administrator mode - Detect
550 Csharp Files - File exists
552 Csharp Files - Hide a file
553 Basic4Android Files - Determine startup path
554 Basic4Android SQLite - Read a single query
555 Csharp SQLite Remove a record
556 Csharp SQLite Clear entire database
557 Csharp SQLite Insert into database (parameters)
558 Csharp SQLite Update query
559 Csharp SQLite Update with parameters
561 Csharp SQLite Update Image with parameters
563 Csharp SQLite Read Image from database to file
564 Csharp SQLite Read Image from database to picturebox
565 Csharp ListBox - Rename Item
566 Csharp ListBox - Save all items
567 Csharp ListBox - Load all items
568 Basic4Java Examples - TableView
569 PHP mySQL Close connection
570 PHP ForEach
571 PHP For Next loop
572 PHP Passing variables in a URL
573 PHP mySQL - insert into database (one.com)
574 PHP mySQL Prepared statements
575 One.com mySQL add city
576 One.com mySQL add zip
578 One.com UTF 8859-1
579 mySQL Create table orders
581 PHP Delete
582 mySQL Rename table
583 HTML Basic structure
584 HTML Color Text
585 HTML Color Background
586 HTML Font
587 HTML Font size
588 HTML Text Centered
589 HTML Text Bold
590 HTML Text Strong
591 HTML Text Italic
592 HTML Text Emphasized
593 HTML Text Small Formatting
594 HTML Text Marked Text
595 HTML Text Overlined Text
596 HTML Text Underlined Text
597 HTML Text Lowered Text
598 HTML Text Highered Text
599 HTML Text Quotation Marks
600 HTML Text Blockquote
601 HTML Text Abbr
602 HTML Text Address
603 HTML Comment
604 HTML Color Text examples
605 HTML Color RGB
606 HTML Color RGB Gray
607 HTML Color One line of text
608 HTML CSS Link
609 HTML CSS Border around text
610 HTML CSS Padding
611 HTML CSS Margin
612 HTML CSS ID
613 HTML CSS Color of links
614 HTML Image as link
615 HTML HTML links
616 HTML Jump to chapter
618 HTML Alt
619 HTML Image show
620 HTML Image show (in another folder)
621 HTML Image mapping
622 HTML Table Simple layout
624 HTML Table double border layout
625 HTML Table single border layout
626 HTML Table border cell padding
627 HTML Table border left-align headings
628 HTML Table border spacing
629 HTML Table border Cell that spans two columns
630 HTML Table color
631 HTML Table multiple colors
633 jQuery Init
634 HTML Combobox
635 HTML Play sound
636 HTML Text Colored selection
638 HTML CSS Button gray
639 HTML CSS Textarea
640 HTML Basic structure 2
641 HTML Form Signup
642 PHP mySQL Connection basic
644 PHP Signup.php
645 PHP Logged in.php
646 PHP Array
647 PHP Constant
648 PHP Include once
652 PHP Include standard
654 PHP Login check
655 HTML Button Clickable
656 PHP Save textfile
658 Basic4Java Mouse position (Entire screen)
659 Basic4Java Topmost
660 Basic4Java Run external file
661 Basic4Java Files - Exists
662 Basic4Java Files - Exists 2
664 Basic4Java Folders - Exists
665 Basic4Java Rotate canvas
666 Basic4Java Hotkey
667 Basic4Java Show Hide Min Max buttons
668 Basic4Java Screen resolution
669 PHP Files - Load textfile
670 PHP Folder - Remove folder
671 PHP Files - Delete file (unlink)
672 PHP Files - Delete all files
673 PHP Files - Delete files
674 PHP Files - Delete PHP files
675 PHP Files - Delete files and folders
676 PHP Valid chars
677 PHP Valid email
678 PHP Valid URL
679 PHP Example - email form
680 PHP Example - Keep values in form
681 Basic4Java Clipboard - Clear
682 Unity PlayerController 3D Basic
684 Unity Rotate object
685 Csharp SQLite - Basic connection
686 Csharp SQLite - DataGrid
687 WPF Timer
688 Csharp Crypt.cs
689 WPF Text Color
690 WPF Extended toolkit
692 WPF Extended toolkit Messagebox
693 Unity Rotate 2D
694 Csharp Keypress - Accept only numbers
695 WPF Image (Code behind)
697 WPF Binding
699 PHP mySQL Insert Standard
700 PHP mySQL Insert with parameters
701 PHP mySQL List
702 PHP Delete file
703 PHP Connected
704 PHP Login (Local password)
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
OK no problem, On each iteration of the loop a new Array (arr()) is created and populated with a row from the list (L).

If you want to keep the data in memory, I would suggest you use a Type to hold each record and store them in a list. A list is simpler than an array as you don't need to know how many items there will be in advance. I don't know what your 7 field names would be but you can easily change them.

In Process_Globals:

B4X:
    Type MyDataType ( _
        ID As String, _
        Environment As String, _
        Task As String, _
        Field4 As String, _
        Field5 As String, _
        Field6 As String, _
        Field7 As String)
       
        Dim MyDataList As List

Then where you are loading the data:
B4X:
MyDataList.Initialize
    For Each Arr() As String In L
        Dim MDT As MyDataType
        MDT.Initialize
        MDT.ID = Arr(0)
        MDT.Environment = Arr(1)
        MDT.Task = Arr(2)
        MDT.Field4 = Arr(3)
        MDT.Field5 = Arr(4)
        MDT.Field6 = Arr(5)
        MDT.Field7 = Arr(6)
       
        MyDataList.Add(MDT)
    Next


Then to read one:

B4X:
Dim MDT As MyDataType = MyDataList.Get(10) ' Or whichever you want to read
Log($"${MDT.ID} ${MDT.Environment} ${MDT.Task}"$) 'etc
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Thanks, I will investigate types with B4J further. It looks a bit complex with all the ${} signs :)
Even though it's great to learn from I am not sure if it's good practice to store and work with database contents in memory, other than to just allow the user to make changes to the database and then have it reloaded into the tableview. I'm trying to find 'the best way' or at least one way that is 'the preffered way' so to speak.
Since you are more experienced with B4J and DButils it's of great value to know your advice and recommendations how to properly work with database handling.
DButils seems like a convenient module for viewing database contents prefferably with the tableview control, at least that's my own experience. The mic is yours Steve.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I fine the smart strings easier to use that concatenating strings for output:
B4X:
Log($"${MDT.ID} ${MDT.Environment} ${MDT.Task}"$)

Could just as easily have been
B4X:
Log(MDT.ID  & " " & MDT.Environment & " " & MDT.Task)

DBUtils is a very useful Code module, however it is still sometimes easier to use the SQLite queries directly, especially the ExecQuerySingleResult and variants. You should become familiar with DBUtils and the direct SQLite calls and use the one that is more appropriate to the task in hand.

Design of the database is critical to getting the data in and out in an efficient manner, so you need to consider how the data is coming in, and how you want to access the data and create tables in a structure that makes it simplest. If you are using multiple tables, become familiar with the JOIN facility of SQLite.

Invariably if you are writing something new 'on the fly' things will change and you may need to change the database structure before you have finished. Which is why planning is Key. If you can get it as close as possible on the first attempt, it can save a lot of time and data re-entry.
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Thanks, I will organize my code in code modules since it seems like the whole point with modules in the first place, and after studying your code.
I had no idea about those smart strings in B4X, those reminds me of string handling in C sharp. Good planning is really something to considder every time.
Before wrapping up this post I have summed up some questions that will make life easier when working with DButils and databases. It will help others as well.

  • Is it possible to work the same way with remote databases i.e. a mySQL remote database with B4J-DButils-MySQL-TableView, as with a local SQLite database?
  • How to hide a tableview column for example with database Id's in the first tableview column, that can work as a reference to the database. How to do that?
  • Can you give examples on when to use JOIN, you mentioned that it's especially useful when working with multiple columns?

Happy-New-Year-2017.jpg
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
I answer the second question myself, in case it might help someone else

tableView1.SetColumnVisible(x, False)
Were x is the column to hide. 0 for the first column, 1 second column etc.
And last parameter is visible True/False.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Is it possible to work the same way with remote databases i.e. a mySQL remote database with B4J-DButils-MySQL-TableView, as with a local SQLite database?

I doubt it, I don't know mySQL but DBUtils was written for SQLite. I don't know if there is any compatibility in the command syntax, but you could create a DBUtils module to work with it using code from the existing version.

Can you give examples on when to use JOIN, you mentioned that it's especially useful when working with multiple columns?

It would not be a 5 minute job, there are many good tutorials and examples already available on the internet, just be aware that SQLite has facilities to make accessing multiple tables easier and do a Google search when you need it. As always, if you get a problem with implementation, ask on the forums.

Happy New Year to you and all.
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Thanks for pointing this out. I want to share how I could read the first column as hidden, by clicking on the tableView1 (pay attention to the case sensitive name).
I know that there's B4J users in this forum (including myself) who need DButils to support both SQLite and MySQL databases. It would be great if you Steve, or someone
else just as experienced can implement support for mySQL (remote database) support in DButils. Or perhaps as you said, write a custom DButilsMySQL module.
Many of us would be very thankful for the one who do this. Please please please Steve help us with this, and have Erel include it in the new B4J update. I can't wait.

EDIT: I forgot to mention users who set up their own RDC2 server will need DButils to support SQLite and MySQL.

Here's how to read hidden column data when clicking on the tableview
B4X:
Sub tableView1_MouseClicked (EventData As MouseEvent)
    fx.Msgbox(MainForm, tableView1.SelectedRowValues(x), "Hidden column data")
End Sub
where x is the column to read from.
 
Last edited:
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I'm afraid I don't know mySQL and currently have no need for it. I couldn't justify spending the time required to learn to use it. Perhaps someone already conversant in it may take up the challenge, if it's even possible.
 
Last edited:
Upvote 0

ThRuST

Well-Known Member
Licensed User
Longtime User
Perhaps Erel or someone else can give us some advice about DButils-mySQL-tableview. New commands can better be baked into an updated version of DButils by the author of DButils, whoever it was.. whoever it was it is great, but can be even better :)
 
Upvote 0
Top