I am new to ASP.NET and can't seem to find an answer for my problem.
I want to retrieve a list of countries form a table in my database.
I have found a way to do it in C# but i need to do it in Viusal Basic.
private List<Country> PopulateCountry()
using (MyDatabaseEntities dc = new MyDatabaseEntities())
return dc.Countries.OrderBy(a => a.CountryName).ToList();
Private Function GetListOfCountries() As List(Of Country)
Using dc As New MyDatabaseEntities
Dim countryList = (From p In dc.Counties Order By p.CountryName
Catch ex As Exception
Value of type 'List(Of Country)' cannot be converted to 'List(Of Country)'.
I believe this function will suit your needs. (your conversion failed due to
County instead of
County happens to be a valid entity type as well.)
Private Function GetListOfCountries() As List(Of Country) Using dc As New MyDatabaseEntities Try Return dc.Countries.OrderBy(Function(a) a.CountryName).ToList() Catch ex As Exception Return Nothing End Try End Using End Function