Hello, I am new to Xamarin Forms and I have a small project which should allow me to recover data from a MySQL database. I have the connection, but I cannot display the data on my screen. Here are the different codes:
ComptePage.xaml.cs :
using System;
using MySqlConnector;
using TractoApp.Data;
using Xamarin.Forms;
using System.Collections.Generic;
namespace TractoApp.Views
{
public partial class ComptePage : ContentPage
{
public ComptePage()
private void VoirBdd(object sender, EventArgs e)
{
if (Connecté)
{
MySqlCommand cmd = new MySqlCommand("SELECT * FROM ps_customer", cn);
using (MySqlDataReader Lire = cmd.ExecuteReader())
{
var data = new List<MesClients>();
while (Lire.Read())
{
string Prénom = Lire["firstname"].ToString();
string Nom = Lire["lastname"].ToString();
data.Add(new MesClients { firstname = Prénom, lastname = Nom });
}
}
}
else
{
DisplayAlert("Infos:", "Plantage", "Ok");
}
}
}
}
Mes clients.cs :
using System;
using System.Collections.Generic;
using System.Text;
namespace TractoApp.Data
{
public class MesClients
{
public string firstname;
public string lastname;
public MesClients(string firstname, string lastname)
{
this.firstname = firstname;
this.lastname = lastname;
}
public string getFirstname()
{
return firstname;
}
public string getLastname ()
{
return lastname;
}
}
}
ComptePage.xaml
<ListView x:Name="clientsbdd">
<ListView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>Prénom</x:String>
<x:String>Nom</x:String>
</x:Array>
</ListView.ItemsSource>
</ListView>
I have a CS7036 error but I cannot manage my parameters for the compilation.
Thanks in advance.