原来的写法:

Dim db = From city In DataContext1.AddressCity

Where city.ProvinceID = dgvAddress(2, e.RowIndex).Value.ToString  、

Select city.CityID, city.CityName.Trim

可以去掉CityName中的空格,但是db中的列名改变了,在绑定Combobox中出现了错误。

修改后的写法:

Dim db = From city In DataContext1.AddressCity
                         Where city.ProvinceID = dgvAddress(2, e.RowIndex).Value.ToString
                         Select New With {.CityID = city.CityID, .CityName = city.CityName.Trim}

可以正确绑定Combobox了。

04-13 16:40