Advice about insert into SQLCE
        Posted  
        
            by Alexander
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Alexander
        
        
        
        Published on 2009-10-13T14:00:16Z
        Indexed on 
            2010/05/23
            1:50 UTC
        
        
        Read the original article
        Hit count: 433
        
.NET
|sql-server-ce
i am inserting about 1943 records by these function into SQLCE.This is my insert function.Parameters come from StringReader(string comes from webservice).This function executes 1943 times and takes about 20 seconds.I dropped table's indexes,what can i do to improve it?I create just 1 time mycomm and sqlceresultset.
Public Function Insert_Function(ByVal f_Line() As String, ByRef myComm As SqlCeCommand, ByRef rs As SqlCeResultSet) As String
    Try
        Dim rec As SqlCeUpdatableRecord = rs.CreateRecord()
        rec.SetInt32(0, IIf(f_Line(1) = "", DBNull.Value, f_Line(1)))
        rec.SetInt32(1, IIf(f_Line(2) = "", DBNull.Value, f_Line(2)))
        rec.SetInt32(2, IIf(f_Line(3) = "", DBNull.Value, f_Line(3)))
        rec.SetInt32(3, IIf(f_Line(4) = "", DBNull.Value, f_Line(4)))
        rec.SetValue(4, IIf(f_Line5(5) = "", DBNull.Value, f_Line(5)))
        rs.Insert(rec)
        rec = Nothing
    Catch ex As Exception
        strerr_col = ex.Message
    End Try
    Return strerr_col
End Function
© Stack Overflow or respective owner