DBEngine.clsLeague.GetTeamsInLeague (Full Version)

All Forums >> [Current Games From Matrix.] >> [Sports] >> Maximum-Football 2.0 >> 3rd Party Developers Area



Message


PackerMan32 -> DBEngine.clsLeague.GetTeamsInLeague (3/25/2007 9:49:09 PM)

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 -> RE: DBEngine.clsLeague.GetTeamsInLeague (3/25/2007 10:48:21 PM)

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?




David Winter -> RE: DBEngine.clsLeague.GetTeamsInLeague (3/26/2007 1:00:51 AM)

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...

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.




David Winter -> RE: DBEngine.clsLeague.GetTeamsInLeague (3/26/2007 1:05:48 AM)

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

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)





PackerMan32 -> RE: DBEngine.clsLeague.GetTeamsInLeague (3/26/2007 3:32:17 AM)

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#.




David Winter -> RE: DBEngine.clsLeague.GetTeamsInLeague (3/26/2007 6:19:34 AM)

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...




Tbird -> RE: DBEngine.clsLeague.GetTeamsInLeague (3/26/2007 8:49:15 AM)

Oooh can't wait to see what's cookin [8D]




PackerMan32 -> RE: DBEngine.clsLeague.GetTeamsInLeague (3/27/2007 12:48:13 AM)

Thanks for the clarification David.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
3.611328