0
我在插入数据到sqlce.I'm阅读字符串和插入到我的表时,我有一个性能问题。在LU_MAM表中,我插入1000个记录8秒。后Mam表我让一些插入,但我最大的表是CR_MUS.When我想插入记录到CR_MUS,它需要太多的时间.CR_MUS有2000个记录,插入需要35秒。什么可以是原因?我在我的插入函数中使用相同的逻辑。任何想法?我使用VS 2008 sp1。Compact Framework中的一个非常有趣的问题
Dim reader As StringReader
reader = New StringReader(data)
cn = New SqlCeConnection(General.ConnString)
cn.Open()
If myTransfer.ClearTables(cn, cmd) = True Then
progress = 0
'------------------------------------------
cmd = New SqlServerCe.SqlCeCommand
Dim rs As SqlCeResultSet
cmd.Connection = cn
cmd.CommandType = CommandType.TableDirect
Dim rec As SqlCeUpdatableRecord
' name of table
While reader.Peek > -1
If strerr_col = "" Then
satir = reader.ReadLine()
ayrac = Split(satir, "|")
If ayrac(0).ToString() = "LC" Then
prgsbar.Maximum = Convert.ToInt32(ayrac(1))
ElseIf ayrac(0).ToString = "PPAR" Then
.
If ayrac(2).ToString <> General.PMVer Then
ShowWaitCursor(False)
txtDurum.Text = "Wrong Version"
Exit Sub
End If
If p_POCKET_PARAMETERS = True Then
cmd.CommandText = "POCKET_PARAMETERS"
txtDurum.Text = "POCKET_PARAMETERS"
rs = cmd.ExecuteResultSet(ResultSetOptions.Updatable)
rec = rs.CreateRecord()
p_POCKET_PARAMETERS = False
End If
strerr_col = myVERI_AL.POCKET_PARAMETERS_I(ayrac, cmd, rs, rec)
prgsbar.Value += 1
ElseIf ayrac(0).ToString() = "MAM" Then
If p_LU_MAM = True Then
txtDurum.Text = "LU_MAM "
cmd.CommandText = "LU_MAM"
rs = cmd.ExecuteResultSet(ResultSetOptions.Updatable)
rec = rs.CreateRecord()
p_LU_MAM = False
End If
strerr_col = myVERI_AL.LU_MAM_I(ayrac, cmd, rs, rec)
prgsbar.Value += 1
ElseIf ayrac(0).ToString = "KMUS" Then
If p_CR_MUS = True Then
cmd.CommandText = "CR_MUS"
txtDurum.Text = "CR_MUS"
rs = cmd.ExecuteResultSet(ResultSetOptions.Updatable)
rec = rs.CreateRecord()
p_TR_KAMPANYA_MALZEME = False
End If
strerr_col = myVERI_AL.CR_MUS_I(ayrac, cmd, rs, rec)
prgsbar.Value += 1
end while
公共功能CR_KAMPANYA_MUSTERI_I(BYVAL f_Line()作为字符串,为ByRef myComm作为SqlCeCommand,为ByRef RS作为SqlCeResultSet,为ByRef REC作为SqlCeUpdatableRecord)作为字符串
Try
rec.SetValue(0, If(f_Line(1) = String.Empty, DirectCast(DBNull.Value, Object), f_Line(1)))
rec.SetValue(1, If(f_Line(2) = String.Empty, DirectCast(DBNull.Value, Object), f_Line(2)))
rec.SetValue(2, If(f_Line(3) = String.Empty, DirectCast(DBNull.Value, Object), f_Line(3)))
rec.SetValue(3, If(f_Line(5) = String.Empty, DirectCast(DBNull.Value, Object), f_Line(5)))
rec.SetValue(4, If(f_Line(6) = String.Empty, DirectCast(DBNull.Value, Object), f_Line(6)))
rs.Insert(rec)
Catch ex As Exception
strerr_col = ex.Message
End Try
Return strerr_col
End Function