I have a query that executes perfectly in Postgresql:
SELECT
matchid
, f1.firstname
, f1.lastname
, f2.firstname
, f2.lastname
FROM matches AS m
INNER JOIN fighters AS f1
ON f1.fighterid = m.fighteroneid
INNER JOIN fighters AS f2
ON f2.fighterid = m.fightertwoid
It displays one row with the fighters, but when I attempt to display the results in a combo box it displays as “System.Data.DataRow” as opposed to the data.
Code in VB.NET:
mySelectQuery = "SELECT f1.firstname, f1.lastname, f2.firstname, f2.lastname FROM matches AS m INNER JOIN fighters AS f1 ON f1.fighterid = m.fighteroneid INNER JOIN fighters AS f2 ON f2.fighterid = m.fightertwoid"
pgAdapter = New PgSqlDataAdapter(mySelectQuery, pgConnection)
pgAdapter.Fill(dtMatches)
With cboMatches
.DisplayMember = "fighters"
.ValueMember = "matchid"
.DataSource = dtMatches
.SelectedIndex = -1
End With
I have attempted to use fighters, m, f1, f2 as display member and it always returns the same output.
If I move the .DataSource above .DisplayMember I recieve the error: Cannot bind to the new display member. Parameter name: newDisplayMember.
Thank you in advance,
Spence
ValueMember and DisplayMember should refer to column names of your datasource.
You don’t have anything with the names assigned.
You could try to assign one name to the DisplayMember, but your query doesn’t produce any MatchID.
I am not an expert in PostegreSQL, but, you could try the following to aggregate the names
and then use