vb.net - Populate dropdown box from SQL Server using a function -


i trying follow video written in c# , convert vb (to populate dropdown box sql server using function) here working c# code:

private list<product> getallprodcuts() {     try     {           using(propsolwebdbentities db= new propsolwebdbentities())           list<product> products = (from x in db.product select x).tolist;     }     catch(exception)     {            return null;     } } 

and vb cant work:

private function getallproducts() list( of<product>)          try             dim db new propsolwebdbentities             dim products list <product> = (from x in db.product select x).tolist               return products          catch ex exception             return vbnull         end try     end function 

what doing wrong?

list should translated list(of product).

return null should translated return nothing.

use using instead of declaring db variable.

i don't compile code, it's this:

private function getallproducts() list(of product)  try     using db new propsolwebdbentities         dim products list(of product) = (from x in db.product select x).tolist()         return products     end using  catch ex exception     return nothing end try 

end function


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -