Adding a New Team throws an error

Topics: Developer Discussion
Aug 1, 2007 at 4:52 PM
I am trying to use the "New Team" link on the Statistics page to add a new team. I am getting the following error: "Conversion from string "" to type 'Integer' is not valid". The problem appears to be in the following piece of code.

Public Shared Sub AddTeam(ByVal seasonid As String, ByVal teamname As String, ByVal coachmemkey As Object)
Dim meminf As New MemberInfo(MemberInfo.Columns.Memberid, coachmemkey)
Teams.Insert(teamname, seasonid, meminf.Memberid)
End Sub

Here seasonid="" and the code in Teams.Insert() is trying to convert it to an Int.

Has anyone ran into this issue? Thanks!
Coordinator
Aug 1, 2007 at 6:34 PM
There is actually an easy fix for that.

Public Shared Sub AddTeam(ByVal seasonid As String, ByVal teamname As String, ByVal coachmemkey As Object)
Dim meminf As New MemberInfo(MemberInfo.Columns.Memberid, coachmemkey)
Teams.Insert(teamname, Integer.Parse(seasonid), meminf.Memberid)
End Sub
Aug 1, 2007 at 6:45 PM
I know, I tried that only to discover that there is a FOREIGN KEY constraint on "FKTeamsSeasons" that prevent inserting a team with seasonid=0. The problem in fact is that seasonid="" when it should not be.

I can make it work, but I wanted to make sure this was not just me having the issue.

Thanks a lot for all the great work you are doing!
Coordinator
Aug 1, 2007 at 9:35 PM
So you want to remove that dependency?

To do so, crack open the Database in the Server Explorer. Open the Teams table and open "relationships" and remove the foreign key.
Mar 16, 2010 at 5:56 PM
chazim wrote:
I know, I tried that only to discover that there is a FOREIGN KEY constraint on "FKTeamsSeasons" that prevent inserting a team with seasonid=0. The problem in fact is that seasonid="" when it should not be.

I can make it work, but I wanted to make sure this was not just me having the issue.

Thanks a lot for all the great work you are doing!

Hi chazim, did you ever figure out how to fix this error? 

I tried z2bass' suggest and have the same error.