我试图将数据从数据库带入dataTable,记录大约为600万。 我们知道DataTable Limit 16,777,216
参考:http://msdn.microsoft.com/en-us/library/system.data.datatable.aspx
但是我的dataTable仅在250万条记录中耗尽了内存。我不知道为什么?
public DataTable Func(int totalRecords)
{
SqlDependency.Start(ConfigurationManager.AppSettings["ConnectionString"].ToString());
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter();
sda.SelectCommand = new SqlCommand();
sda.SelectCommand.CommandText = "SP_NAME";
sda.SelectCommand.Transaction = sqlTrans;
sda.SelectCommand.Connection = this.connection;
sda.SelectCommand.CommandType = CommandType.StoredProcedure;
SqlCacheDependency dependency = new SqlCacheDependency(sda.SelectCommand);
if (connection.State == ConnectionState.Closed)
connection.Open();
dt.Load(sda.SelectCommand.ExecuteReader(CommandBehavior.CloseConnection));
return dt;
}
答案 0 :(得分:0)
它是可执行文件吗?如果是这样,请确保
Project Settings -> Build -> Prefer 32-bit
未选中