DBEngine.clsLeague.GetTeamsInLeague

A section for those creating 3rd party tools and add ons. Lots of techincal code creation type questions would go here.

Moderator: David Winter

Post Reply
PackerMan32
Posts: 15
Joined: Sat May 06, 2006 6:27 am

DBEngine.clsLeague.GetTeamsInLeague

Post by PackerMan32 »

I am back to working on Utilities for Maximum football and have come to a problem. I am using the provided DBEngine DLL to retrieve some to the team data, but I cannot seem to get a team object out of the provided interfaces. I have my clsLeagueData object and I want to retrieve every team, conference, and division in that league and I thought that the GetTeamsInLeague function would do this for me. However, everytime I use this function it returns a null collection. Is this function not implemented yet? Also, what are valid vOrderBy parameters to pass to this function. Hopefully David or any other developer familiar with the MF API can help me out here. I am programming in C#. Thanks!
PackerMan32
Posts: 15
Joined: Sat May 06, 2006 6:27 am

RE: DBEngine.clsLeague.GetTeamsInLeague

Post by PackerMan32 »

Okay, I now have got a collection of team id's fromt he GetTeamsInLeague function. But this is not what I need. I'm not quite sure how to extract a team data object or load a team data object using the DBEngine api. Any advice?
User avatar
David Winter
Posts: 5158
Joined: Tue Nov 23, 2004 10:51 pm
Location: Vancouver, BC
Contact:

RE: DBEngine.clsLeague.GetTeamsInLeague

Post by David Winter »

vOrderBy is the name of the field in the Teams database table you wish to order the records by. It gets used in the Select statement of the query. 
 
Starting from the point you have the teamID...
 

Code: Select all

 Dim CTeam as DBEngine.clsTeamData
  
 Set CTeam = new DBEngine.clsTeamData
 call CTeam.GetRecord("ID=" & mTeamIDObtainedPreviously)
 
 With CTeam
  '//Do things with the team
 End With
  
 set CTeam = Nothing '//Clean up when done.
 
 
Sometimes the DBEngine will return a team data class (or player data class). Use the Object Browser(F2) to to find out what a particular API will return.
 
There are no functions in the DBEngine that are not implemented. All functions do something, so if it's not doing anything, it's likely that you're not using the function correctly.
 
One thing to keep in mind if you're programming in C# is that DBEngine returns a type VBA.CollectionClass and those are not compatible with Collections in C# (I don't even think C# has a sense of collections in the VB sense). So you may need to do some sort of cast (or do a manual loop through conversion) to get them to the object type you need.
 
Also be aware that your application will need to be compiled to specific builds of DBEngine.dll. As I make fixes or add new features at users requests, the DBEngine will break binary compatibility.
"They're not dolls. They're action figures. Valuable Action figures!"
User avatar
David Winter
Posts: 5158
Joined: Tue Nov 23, 2004 10:51 pm
Location: Vancouver, BC
Contact:

RE: DBEngine.clsLeague.GetTeamsInLeague

Post by David Winter »

Ohh wait.. GetTeamsInLeague returns a collection of clsTeamData Classes already so all you need to do is this;

Code: Select all

 Dim CTeam as DBEngine.clsTeamData
 Dim colTeams as Collection
 
 (open the league database)
 
 set colTeams = mLeagueData.GetTeamsInLeague("City")
 
 if colTeams.Count > 1 then
 Set CTeam = colTeams(1) '//As an example, set the team to the first one returned in the collection
 
 '//Now do something with the team.
 
 End if
 
 '//Clean up when done
 set colTeams = nothing
 set CTeam = nothing
 

If you want specific teams in a division, you need to use the GetTeamsInDivision function (and pass in the divisionID)

"They're not dolls. They're action figures. Valuable Action figures!"
PackerMan32
Posts: 15
Joined: Sat May 06, 2006 6:27 am

RE: DBEngine.clsLeague.GetTeamsInLeague

Post by PackerMan32 »

Ok that's what I was trying to do. C# does have a VBA.Collection object so I can use that. I did get it to work, however it will only work when I pass an empty string as the vOrderBy parameter. If I pass anything else it will return a null collection. I'll do some more research and see if I can't figure out why it is failing.

I think that was my problem previously, I had always passed a field name as the vOrderBy parameter because I figured that's how it would sort the collection. I did notice however that it requests that the parameter is sent by Reference, which means in C# instead just calling the function like GetTeamsInLeague("City") I need to call it as such GetTeamsInLeague(ref vOrderBy), where vOrderBy is the string containing the order field. I'm wondering if the by reference requirement isn't messing it up because the string data types aren't the same between VB6 and C#.
User avatar
David Winter
Posts: 5158
Joined: Tue Nov 23, 2004 10:51 pm
Location: Vancouver, BC
Contact:

RE: DBEngine.clsLeague.GetTeamsInLeague

Post by David Winter »

Hmmm you're right, it is passing it in as reference.. that's my mistake.. it should have been by value. Well, minor issue that shouldn't cause any problems as long as you're aware of it.
 
That said, I've gone through my core game code and have noticed I'm no longer passing in any paramaters to that function so the vOrderBy is probably dead code and you should just use a null string for that...
"They're not dolls. They're action figures. Valuable Action figures!"
User avatar
Tbird
Posts: 683
Joined: Wed Dec 15, 2004 12:28 am
Contact:

RE: DBEngine.clsLeague.GetTeamsInLeague

Post by Tbird »

Oooh can't wait to see what's cookin [8D]
PackerMan32
Posts: 15
Joined: Sat May 06, 2006 6:27 am

RE: DBEngine.clsLeague.GetTeamsInLeague

Post by PackerMan32 »

Thanks for the clarification David.
Post Reply

Return to “3rd Party Developers Area”