PDA通过WEB SERVICE下载数据(返回的DATASET),然后插入到PDA的SQLCE数据库中,但是很慢啊,例如一批5000多条数据,从下载到插入到SQLCE中要用5分钟左右的时间,不知道有没有什么优化的办法,下面是代码:
WEB SERVICE部分:
[WebMethod]
public DataSet getCheckData2(string depID,string strWhere)
{
try
{
string strSql = "select Zc_ID,Zy_Name,Jz_Name,Zc_Flcode,Zc_Flmc,Zc_Code,Zc_Name,Zc_Ggxh,Zc_Zzcs,Zc_Dw,Zc_Sl,Zc_Zcyz,Zc_Dept" +
",Dep_Name,Zc_Zrr,Zc_Azwz,Zc_Bgqk,Zc_Flxh,Zc_Syqk,Zc_Zczjl,Zc_Hdrq,Zc_Synx,Zc_Ysynx,Zc_Zcxz,Zc_Zje," +
"Zc_Mark,isnull(Zc_PdCount,0)Zc_PdCount,isnull(Zc_PdDate,'2014')Zc_PdDate,Zc_PdStatus " +
" from View_ZcInfo where Zc_IsDel='0' and Zc_Dept='" + depID + "' and Zc_PdStatus='盘亏'";
strSql += strWhere;
DataSet ds = DataBySQL.GetDataSet(strSql, " ");
return ds;
}
catch (Exception ee)
{
return null;
}
}
PDA部分:
Cursor.Current = Cursors.WaitCursor;
SqlCeConnection conn = dbComponent.GetConnection();
SqlCeCommand comm = new SqlCeCommand();
SqlCeTransaction trans = conn.BeginTransaction();
comm.Connection = conn;
comm.Transaction = trans;
try
{
DateTime dtBegin = DateTime.Now;
DataSet myDS = service.getCheckData2(App_Code.DeptInfo.depID, "");
dbComponent.Message_Info((DateTime.Now - dtBegin).ToString());
if (myDS.Tables.Count == 0)
{
dbComponent.Message_Info("PC上没有此部门盘点信息!");
Cursor.Current = Cursors.Default;
return;
}
for (int i = 0; i < myDS.Tables[0].Rows.Count; i++)
{
string inserCheck = "INSERT INTO AssetPd VALUES('" + myDS.Tables[0].Rows[i][0].ToString().Trim() + "','"
+ myDS.Tables[0].Rows[i][1].ToString().Trim() + "','"