我正在执行 SQL 查询并将找到的行写入临时数据集。在 Windows 移动设备上,这大约需要 10-12 秒。在从设备进行一些调试之后,我发现大部分延迟都在adapter.Fill(tempDataset);
(7-9 秒)。
我能做些什么来解决这个问题?我需要做什么来加快 DataAdapter.Fill?为什么要花这么多时间?
我正在使用SQL Server CE
和CompactFramework 3.5
。
string connectionString = @"Data Source='/pathto/MYDataBase.sdf'; Max Database Size = 512; Max Buffer Size = 4096;";
string strSql = "SELECT * FROM item WHERE LastName = '" + stringLastName + "'";
SqlCeConnection mConnection = new SqlCeConnection(connectionString);
SqlCeCommand mCommand = new SqlCeCommand(strSql, mConnection);
// Read all rows from the table into a dataset
SqlCeDataAdapter adapter = new SqlCeDataAdapter(mCommand);
tempDataset = new MYDataSet();
adapter.Fill(tempDataset);