Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Optimizing speed result on this code
Message
De
05/02/2008 02:00:20
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Optimizing speed result on this code
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01289437
Message ID:
01289437
Vues:
60
Is there a way to optimize the speed result on this code:
        ' Adjust a dataset to avoid null values
        ' expO1 Dataset
        Public Function AdjustDataSetToAvoidNullValue(ByVal toDataSet As DataSet) As DataSet
            Dim ldDate As Date = oApp.GetEmptyDate()
            Dim loColumn As DataColumn
            Dim loRow As DataRow
            Dim loTable As DataTable

            For Each loTable In toDataSet.Tables
                For Each loRow In loTable.Rows
                    For Each loColumn In loTable.Columns
                        If IsDBNull(loRow.Item(loColumn.ColumnName)) Then

                            Select Case loColumn.DataType.ToString

                                Case "System.DateTime"
                                    loRow.Item(loColumn.ColumnName) = ldDate

                                Case "System.Integer"
                                    loRow.Item(loColumn.ColumnName) = 0

                                Case "System.Decimal"
                                    loRow.Item(loColumn.ColumnName) = 0

                                Case "System.Boolean"
                                    loRow.Item(loColumn.ColumnName) = False

                                Case Else
                                    loRow.Item(loColumn.ColumnName) = ""

                            End Select

                        End If
                    Next
                Next
            Next

            Return toDataSet
        End Function
On a 7000 records dataset, which contains a lot of fields, this process can take up to 4 seconds.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform