MjH
Posts: 165
Joined: 2/23/2006 Status: offline
|
First a disclaimer: All the coding I have done in the past decade has been in Oracle PL/SQL and Java, so I have no clue about Visual Basic, therefore what I'm proposing may not be the best way to do what you want in VB. However, I assmume that VB has way of returning a list of rows when executing a query against a database. What I would do would be something like (note, most of the following is psuedo-code, not actual VB syntax):
sqlStatement = "SELECT T.ID, T.TeamName FROM Teams T, LeagueDivisions L WHERE T.DivisionId = L.ID ORDER BY L.Name, T.TeamName";
listOfRows = executeQuery(sqlStatement);
Dim teamNameArray()
Dim teamIDArray()
teamSize = 0;
while (listOfRows has another entry) do
listOfRows.next
ReDim Preserve teamNameArray(teamSize)
ReDim Preserve teamIDArray(teamSize)
teamNameArray(teamSize) = listOfRows.TeamName
teamIDArray(teamSize) = listOfRows.ID
teamSize = teamSize + 1
end while;
You now have two arrays, one with the team names, and one with the team ids. Use the teamNameArray to build your list box, and when the user selects an entry in the list, you can use the index of that team in the teamNameArray to find the ID in the teamIDArray to use in other queries. Does that help any?
|