这是我的代码,它可以正常工作,直到我的数据库在主表中的记录不超过 20000 条。当 DB 到大程序时,在语句 da.Fill(data) 处冻结。没有异常抛出,程序只是停止工作。我能做些什么?
DataTable data = new DataTable();
SqlCeCommand cmd = new SqlCeCommand();
SqlCeDataAdapter da = new SqlCeDataAdapter();
cmd = new SqlCeCommand("SELECT DISTINCT * FROM ((Osoba AS a LEFT OUTER JOIN Doswiadczenie AS b ON a.HashId = b.Hashid) LEFT OUTER JOIN Wyksztalcenie AS c on a.HashId = c.HashId) INNER JOIN Uczelnia as d ON c.UczelniaId = d.UczelniaId WHERE a.DataOstOdczytu >= @minDate AND a.DataOstOdczytu <= @maxDate AND b.DataOdczytu >= @minDate AND b.DataOdczytu <= @maxDate AND c.DataOdczytu >= @minDate AND c.DataOdczytu <= @maxDate", this.Connection);
cmd.Parameters.Add(new SqlCeParameter("@minDate", minDate));
cmd.Parameters.Add(new SqlCeParameter("@maxDate", maxDate));
da.SelectCommand = cmd;
try
{
da.Fill(data);
}
catch (System.Data.SqlServerCe.SqlCeException)
{
throw;
}
return data;