Populate a listview with 2 BO


Author
Message
David Daragon
David Daragon
StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)
Group: Forum Members
Posts: 54, Visits: 249
Hi,

I have a listview in my form.

I succeed to populate it with this method:

public void RecupererToutesVilles()
{
SqlCommand _maRequeteSQL = new SqlCommand();

_maRequeteSQL.CommandText = "SELECT Pk_DaVille, Libelle, CodePostal, Fk_DaPays, PhxLibelle, MajLibelle FROM L_DaVille";
this.FillDataTable(_maRequeteSQL);
}

But in my listview, I have a foreign key of a country whereas I want to see the name of the country.
So I want my query to be like these.

_maRequeteSQL.CommandText = "SELECT Pk_DaVille, L_DaVille.Libelle, CodePostal, Fk_DaPays, F_DaPays.Libelle, L_DaVille.PhxLibelle, L_DaVille.MajLibelle FROM L_DaVille INNER JOIN F_DaPays ON (L_DaVille.Fk_DaPays = F_DaPays.Pk_DaPays)";

I tried to add a display field called F_DaPays.Libelle in the PopulationDataSourceSettings but I have an error.

Can someone help me please.
Regards,

David

Michel Levy
Michel Levy
StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)
Group: StrataFrame Users
Posts: 193, Visits: 9K
David,

Ta requète comporte un JOIN, le mieux est de créer une vue sur ton serveur SQL (éventuellement en lecture seule), tu profiteras au mieux du plan d'optimisation de SQL.
Et tu pointes ta requète sur cette vue pour peupler ton Listview

--

You have a JOIN in your query, so you'd create a view on your SQL server (possibly read-only) to benefit from SQL execution plan.
And you query against that view to populate your Listview

David Daragon
David Daragon
StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)
Group: Forum Members
Posts: 54, Visits: 249
David,

Ta requète comporte un JOIN, le mieux est de créer une vue sur ton serveur SQL (éventuellement en lecture seule), tu profiteras au mieux du plan d'optimisation de SQL.
Et tu pointes ta requète sur cette vue pour peupler ton Listview

--

You have a JOIN in your query, so you'd create a view on your SQL server (possibly read-only) to benefit from SQL execution plan.
And you query against that view to populate your Listview

Cela veut donc dire que je ne passe pas par un BO (ni donc par la propriété PopulationDataSourceSettings) pour peupler ma liste mais directement via une requête qui attaquera ma vue ?

Michel Levy
Michel Levy
StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)StrataFrame User (437 reputation)
Group: StrataFrame Users
Posts: 193, Visits: 9K
Pourquoi? une fois ta vue définie sur ton serveur, tu peux la requèter depuis un BO en définissant une méthode FillDataTable, que tu choisiras pour peupler ton ListView.

Il me semble que c'est l'expérience VFP qui te manque, là BigGrin. Tous les controles de type liste sont doublement liés aux données: d'une part pour les peupler, d'autre part pour affecter leur valeur à un champ.

--

Why? when your view is defined on your server, you may query it from a BO, using a FillDataTable method, and you'll choose that method to fill the ListView.

It seems as a missing VFP background BigGrin. All list controls are double data-binded: on the one hand for populating, on the other hand for setting a value to a field.

David Daragon
David Daragon
StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)StrataFrame Novice (88 reputation)
Group: Forum Members
Posts: 54, Visits: 249
Thanks Michel

I tried and it works.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search