question

yusuf2 avatar image
0 Votes"
yusuf2 asked YonglunLiu-MSFT answered

SQLite - loop through records


Hi,
How can I loop through sqlite table, I can view
Data in ListView using xaml, but I want to deal with each row individually , example display each BookTitle in displayAlert.


 using System;
 using System.IO;
 using Xamarin.Forms;
 using Xamarin.Forms.Xaml;
    
 namespace App1
 {
     [XamlCompilation(XamlCompilationOptions.Compile)]
     public partial class MainPage : ContentPage
     {
         string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "database.db3");
         public MainPage()
         {
             InitializeComponent();
         }
    
         protected override async void OnAppearing()
         {
               listView.ItemsSource = await App.Database.GetBooksAaync();
         }
     }
 }


dotnet-csharpdotnet-xamarindotnet-sqlite
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

yusuf2 avatar image
0 Votes"
yusuf2 answered
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

YonglunLiu-MSFT avatar image
0 Votes"
YonglunLiu-MSFT answered

Hello,

As the documentation you found, you can use the following steps for looping each record:

Step1: Get the records from a table in database.

Step2: Use foreach to loop each record.

Best Regards,

Alec Liu.




If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.