简体   繁体   中英

Handling large data from webservice to SQL Server CE database

In a windows mobile application I am calling a web service to retrieve large amounts of data which returns data in the form of array List. After that I am inserting the data to SQL Server CE database inside the device. Right now its taking too much time as there are lot of tables and large amount of data for each table. Please suggest a faster way to insert data to SQL Server CE database using Array list .

ce_command.Connection = Database.GetDbConnection();
ce_command.CommandType = CommandType.TableDirect;
ce_command.CommandText = "NHH_SOURCE";
System.Data.SqlServerCe.SqlCeResultSet rsSource;
SqlCeUpdatableRecord recSource;
rsSource = ce_command.ExecuteResultSet(System.Data.SqlServerCe.ResultSetOptions.Updatable);
recSource = rsSource.CreateRecord();
NPFWebService.WebServiceGetNHH_Source[] get_source = null;
get_source = npf_WS.GetSourceData();

if (get_source.Length > 0)
{
    for (int i = 0; i < get_source.Length; i++)
    {
        recSource.SetValue(0, get_source[i].sourceID);
        recSource.SetValue(1, get_source[i].sourceName.Replace("'", "''"));
        recSource.SetValue(2, get_source[i].organizationID);
        recSource.SetValue(3,get_source[i].transferF);
        recS‌​ource.SetValue(4, get_source[i].transferDate);
        rsSource.Insert(recSource);

Looks like your are already using the fastest approach. Does you table have an index (or indexes) - you might be able to save some time by dropping and recreating after the insert is complete

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM