customlistview and database

doogal

Member
Licensed User
Longtime User
Hello all,

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.

Thanks in advance.
Doogal
2v9qcn7.png
 

doogal

Member
Licensed User
Longtime User
Hi Erel,
Thank you for your response.

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.

Thank you for your time.
Doogal
2r3wbrn.png
 

Attachments

  • pattern.zip
    17.8 KB · Views: 297
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
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
 
Upvote 0

asales

Expert
Licensed User
Longtime User
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?

Thanks in advance.
 
Upvote 0

asales

Expert
Licensed User
Longtime User
You should have started a new thread for these questions.
Ok. I will do this.

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.
I see the examples and search in forum but the code not works to me. I will post it in the new thread.
Thanks.
 
Upvote 0
Top