'Declare Variables
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] league [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SoftballDataSet.LeagueDataTable[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] adapter [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SoftballDataSetTableAdapters.LeagueTableAdapter[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] league_row, row() [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] SoftballDataSet.LeagueRow[/SIZE]
' Create a new row for the table League in my Database
[SIZE=2]league_row = league.NewRow()[/SIZE]
' Take the name the user inputted in a text box and create the new row using this name and an auto generated ID
[SIZE=2]league_row.League_Name = LeagueNameTextBox.Text[/SIZE]
' Not really important to you here...just helps me keep up with stuff later on in the program
[SIZE=2]Softball_Module.CurrentLeague.SetLeagueName(LeagueNameTextBox.Text)[/SIZE]
' Add the row and update the database
[SIZE=2]league.Rows.Add(league_row)[/SIZE]
[SIZE=2]adapter.Update(league)[/SIZE]
' Here's where I try to find the new row. I search for any rows that contains the text the user inputted in the text box and store it in an array of rows
[SIZE=2]row = league.Select([/SIZE][SIZE=2][COLOR=#800000]"League_Name Like '"[/COLOR][/SIZE][SIZE=2] & Softball_Module.currentLeague.GetLeagueName() & [/SIZE][SIZE=2][COLOR=#800000]"'"[/COLOR][/SIZE][SIZE=2])[/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] x [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][SIZE=2] = 0[/SIZE]
[SIZE=2][COLOR=#0000ff]While[/COLOR][/SIZE][SIZE=2] x < row.Length()[/SIZE]
[SIZE=2][COLOR=#0000ff] If[/COLOR][/SIZE][SIZE=2] row(x).League_Name = Softball_Module.currentLeague.GetLeagueName() [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2] Softball_Module.CurrentLeague.SetLeagueId(row(x).LeagueId)[/SIZE]
[SIZE=2][COLOR=#0000ff] Exit[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]While[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE]
[SIZE=2] x += 1[/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]While[/COLOR][/SIZE]