I have a simple table on a SQL server named Counties with columns ID, Name, and State. I added an ADO.NET Entity Data Model named Model1 and using the wizard created the model from the Db. The Db was named BD and I've done it twice so the context is currently BDEntites2. I have a ComboBox that I'm trying to bind to the Name column. Later I want to make it conditional but for the moment I'm just going to do this. Now I read that EF queries support iListEnermable so I should be able to link them directly but that didn't work. I saw online many examples where a LINQ expression was used and I tried my best to emulate this given later i want to make it conditional but I can't get it to work either.
The form doesn't even load this way and I get an exception if I put this in a button. What am I doing wrong?vb.net Code:
Private Sub Form1_Load() Handles MyBase.Load cbCounty.DataSource = From x In eBD.Counties Where x.State = "MT" Select x.CountyName cbCounty.ValueMember = "CountyName" cbCounty.DisplayMember = "CountyName" End Sub




Reply With Quote
