Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Optimizing speed result on this code
Message
From
05/02/2008 02:00:20
 
 
To
All
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Optimizing speed result on this code
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01289437
Message ID:
01289437
Views:
59
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
Next
Reply
Map
View

Click here to load this message in the networking platform