我发现当我对本地 SQL CE 数据库进行大量插入时,它似乎会崩溃并停止接受新请求。当我同时使用数据填充数据表时(我正在使用委托和工作项(),我在 forloop 中进行了大量更新(但不是那么多System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(ProcessRowObject), id);
),
在工作人员是它停止的地方,我得到了The database file cannot be found. Check the path to the database. [ Data Source = ]
,即使当我创建我使用的连接时
string cnnString = "Data Source=C:/Fastway/Database/Database.sdf";
SqlCeConnection Connection = new SqlCeConnection(cnnString);
当我执行我使用的命令时:
DataAdapter = new SqlCeDataAdapter("", Connection);
var ret = new DataTable();
if (timeOut != 30)
{ //if the DBCon is part of a transaction that already has a timeout set, it keeps getting hosed here.
db.DataAdapter.SelectCommand.CommandTimeout = timeOut;
}
if (ParameterConcat)
{
query = QueryParametersToEmbeddedQuery(query, parameters);
}
else
{
AddParameters(db.DataAdapter.SelectCommand, parameters);
}
db.DataAdapter.SelectCommand.CommandText = query;
try
{
db.DataAdapter.Fill(ret);
}
catch (SqlCeException ex)
{
throw new Exception("SQL query failed: " + query, ex);
}
return ret;
呜呜……是的。我能做些什么?