我是ASP.NET新手,似乎無法找到我的問題的答案。VB.NET ASP.NET檢索列表的數據庫
我想在我的數據庫中檢索一個表格列表。
我發現了一種在C#中做到這一點的方法,但我需要在Viusal Basic中做到這一點。
private List<Country> PopulateCountry()
{
using (MyDatabaseEntities dc = new MyDatabaseEntities())
{
return dc.Countries.OrderBy(a => a.CountryName).ToList();
}
}
這是從C#代碼示例中,我試圖轉換成VB.net,但我不斷收到此錯誤信息,並且不能找出原因。
Private Function GetListOfCountries() As List(Of Country)
Using dc As New MyDatabaseEntities
Try
Dim countryList = (From p In dc.Counties Order By p.CountryName
Ascending
Select p)
Return countryList.ToList()
Catch ex As Exception
Return Nothing
End Try
End Using
End Function
在Return countryList.ToList()
線我得到這個錯誤
Value of type 'List(Of Country)' cannot be converted to 'List(Of Country)'.
任何幫助將非常感激。謝謝!
你有一個錯字,請檢查您的圖片 - '名單(共縣)'VS'名單(國家)' – Fabio