Public Sub FillDataSet(ByRef oDataSet As DataSet, ByVal FillWith As eFill, Optional ByVal sWhere As String = "")
Dim oCommand As New OleDbCommand
Dim oAdapter As New OleDbDataAdapter
Dim s As String
Try
If OpenConnection() Then
oCommand.Connection = mConnection
oCommand.CommandType = CommandType.Text
Select Case FillWith
Case eFill.Colour
If oDataSet.Tables.Contains("ColourVarients") Then oDataSet.Tables.Remove("ColourVarients")
s = "select ColourVarientID, ColourVarientDescription " _
& "from ColourVarients where SubSpeciesID = " & CType(IIf(sWhere = "", 0, sWhere), Integer) & " " _
& "order by ColourVarientDescription"
Case eFill.Species
If oDataSet.Tables.Contains("Species") Then oDataSet.Tables.Remove("Species")
s = "select SpeciesID, SpeciesDescription from Species order by SpeciesDescription"
Case eFill.Status
If oDataSet.Tables.Contains("Statuses") Then oDataSet.Tables.Remove("Statuses")
s = "select StatusID, StatusDescription from Statuses order by StatusDescription"
Case eFill.SupSpecies
If oDataSet.Tables.Contains("SubSpecies") Then oDataSet.Tables.Remove("SubSpecies")
s = "select SubSpeciesID, CommonName " _
& "from SubSpecies where SpeciesID = " & CType(IIf(sWhere = "", 0, sWhere), Integer) & " " _
& "order by CommonName"
End Select
oCommand.CommandText = s
End If
oAdapter.SelectCommand = oCommand
oAdapter.Fill(oDataSet)
Catch ex As Exception
ErrorMessage(meName & " - " & "FillDataSet")
Finally
oCommand.Dispose()
oCommand = Nothing
oAdapter.Dispose()
oAdapter = Nothing
' CloseConnection()
End Try
End Sub