简体   繁体   English

.Net紧凑框架中的性能问题

[英]Performance Problem in .Net compact framework

I cant understand why sending parameters to insert function works slow in .net compact framework. 我无法理解为什么在.net Compact Framework中发送参数以插入函数的速度很慢。

Forexample following code inserts within 2 seconds 例如在2秒内插入以下代码

    cn = New SqlCeConnection(strstring)
    cmd = New SqlCeCommand
    Dim rs As SqlCeResultSet
    cmd.Connection = cn
    cmd.CommandType = CommandType.TableDirect
    cn.Open()
    Dim rec As SqlCeUpdatableRecord
    Dim DB As New Db
    Dim a As Integer = 1
    Dim b As Integer = 2
    For i As Integer = 0 To 1000
        If i = 0 Then
            cmd.CommandText = "A"
            rs = cmd.ExecuteResultSet(ResultSetOptions.Updatable)
            rec = rs.CreateRecord()
        End If
        Try
            rec.SetValue(0, a)
            rec.SetValue(1, b)
            rs.Insert(rec
         Catch ex As Exception

        End Try


    Next

But when i send parameters, a and b,to a insert sub,this code completes within 13 seconds.What does performance decrease? 但是,当我向插入子发送参数a和b时,此代码在13秒内完成。性能会降低什么?

 cn = New SqlCeConnection(strstring)
    cmd = New SqlCeCommand
    Dim rs As SqlCeResultSet
    cmd.Connection = cn
    cmd.CommandType = CommandType.TableDirect
    cn.Open()
    Dim rec As SqlCeUpdatableRecord

    For i As Integer = 0 To 1000
        If i = 0 Then
            cmd.CommandText = "A"
            cmd.CommandType = CommandType.TableDirect
            rs = cmd.ExecuteResultSet(ResultSetOptions.Updatable)
            rec = rs.CreateRecord()
        End If
        Try
            DB.Insert(1, 2, rs, rec)
        Catch ex As Exception

        End Try


    Next 

This is insert sub in db class 这是db类中的插入子

Public Class Db 公开课Db

Public Shared Sub Insert(ByVal a As Integer, ByVal b As Integer, ByRef rs As SqlCeResultSet, ByRef rec As SqlCeUpdatableRecord)
    Try
        rec.SetValue(0, a)
        rec.SetValue(1, If(b = String.Empty, DirectCast(DBNull.Value, Object), b))
        rs.Insert(rec)
    Catch ex As Exception

    End Try


End Sub

end class 结束班

I would check your installation carefully on the device. 我会仔细检查您在设备上的安装。 It's quite easy to get it mixed up. 混合起来很容易。 The new way to google for the product is SQL Server Compact. 谷歌产品的新方法是SQL Server Compact。

As microsoft decides to change the name of everything in the mobile/CE space, it makes it impossible to search for help. 由于Microsoft决定更改mobile / CE空间中所有内容的名称,因此无法寻求帮助。 Is it Windows CE, or Pocket PC, or Windows Mobile, or Phone 7? 是Windows CE,Pocket PC,Windows Mobile或Phone 7? Is it SQL CE or Sql Server Compact "Arrgh"! 是SQL CE还是Sql Server Compact“ Arrgh”!

Maybe these links will help the next guy. 也许这些链接会帮助下一个家伙。 MSDN Blog or this one Technet . MSDN Blog或这一Technet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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