Concatenating fields in combobox with parameters

Svekke

Member
Joined
Jul 27, 2010
Messages
14
Programming Experience
Beginner
Hi all,

I'm still working on my application to "calculate" prognostics. However, I've encountered a problem which I can't seem to solve with my "basic" VB. NET knowledge. Here is the case:


On the page "prognostics" I have a combobox. In this combobox I would like to display the current match on which you are betting, kinda like this:


"HOMETEAM - OUTTEAM". Each team has a unique ID (1, 2, 3, ... just a sequential number). The database setup looks like this:



TABLE MATCHES

MatchID
MatchDate
.....
Hometeam (foreign key number linked to TEAMID in teamtable)
OutTeam (foreign key number linked to TEAMID in teamtable, but to another team).


TABLE TEAMS
TeamID
TeamName
....

TABLE PROGNOSTICS
MatchID (foreign key number linked to MATCHID in matches)
....


Now is my question: how can I display both teamnames in one combobox, based on the MATCHID. So I'm having a datagridview on this page which currently displays only the MATCHID, but I would like the real teamnames to show up (displaymember), but to still keep the matchid as the valuemember.

Any ideas? This probably is very easy, but I have no idea :-(
 
Well if I understood this properly then it sounds like all you need to do is execute a select statement that will return the hometeam and outteam based on your match id then behind the scenes concatenate those two values into one string with the required format (HomeTeam - OutTeam) and load it into your combo box.
Cheers
 
Hi Frederick,

I believe I know how to create the sql query itself, but how can I load it in my combobox then? Do I have to create a dataset or something? :)
 
Back
Top