public static DataClassesDataContext dataContext = new DataClassesDataContext(); private IQueryable<showAuction> getAuctionsInfo(int dayOfWeek, int pageNo, int pageSize, DataClassesDataContext dataContext) { IQueryable<showAuction> query = from auction in dataContext.showAuctions where auction.DayOfWeek == dayOfWeek select auction; foreach(showAuction s in query){ MessageBox.Show(s.ID+""); } return query; }
foreach循环正确,没异常。但是
使用DataClassesDataContext连接远程数据库时:
C# code
public static DataClassesDataContext dataContext = new DataClassesDataContext("uid=****;pwd=****;Server=****,****;Database=****");