I am using a new object in the designer, CustomView and I don't know how to get data from database into it. I can do this with a regular listview using DBUTILS executelistview. I am following Erels example found here. Could someone show a database example or point me in the right direction.
I am posting a screenshot of what i am trying to accomplish. These were added manually, I want to bring in data from a database.
Were you able to create the layout with the checkbox? You should use DBUtils.ExecuteMemoryTable. Then you should go over the results and use them to create items.
If it doesn't work for you then I'll write a small example.
I tried DBUTILS.ExecuteMemoryTable and it worked however now I am having an object to string conversion problem. I must have not declared something correctly. This has to be something simple, I'm just overlooking it.
ExecuteMemoryTable returns a List that holds arrays of strings. Each array represents a row. In your case there is one item in each array.
B4X:
table = DBUtils.ExecuteMemoryTable(sql1, "SELECT patnum FROM " & dbTable,Null,0)
For Each cols() As String In table
label1 = lvHave.SingleLineLayout.Label
label1.TextSize = 16
lvHave.AddSingleLine(cols(0))
CV1.Add(CreateListItem(cols(0),CV1.AsView.Width, 50dip), 50dip, cols(0))
Next
ExecuteMemoryTable returns a List that holds arrays of strings. Each array represents a row. In your case there is one item in each array.
B4X:
table = DBUtils.ExecuteMemoryTable(sql1, "SELECT patnum FROM " & dbTable,Null,0)
For Each cols() As String In table
label1 = lvHave.SingleLineLayout.Label
label1.TextSize = 16
lvHave.AddSingleLine(cols(0))
CV1.Add(CreateListItem(cols(0),CV1.AsView.Width, 50dip), 50dip, cols(0))
Next
I used the code of this post to execute an SQL that returns several fields and populate a customlistview with a few fields of this SQL:
I have two questions:
1 - I put a checkbox in the customlistview, related with a boolean field in database.
How I can click in this checkbox and update the boolean field in database?
2 - How I can click in a item of customlistview and show all fields of selected item in a messagebox?
You should have started a new thread for these questions.
See the example that comes with CustomListView. It handles a button click and it also includes checkboxes. You need to do something similar in your code.
See the example that comes with CustomListView. It handles a button click and it also includes checkboxes. You need to do something similar in your code.