Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Rounding without decimal
Message
From
04/03/2011 04:54:16
 
 
To
03/03/2011 17:52:25
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01502535
Message ID:
01502611
Views:
37
This message has been marked as a message which has helped to the initial question of the thread.
>>lnLoop = int(lncount/1000)
>
>This works. At first, I tried Math.Int() and thought it was not supported. Now, from your post, I remember that Int() can be used as is.
>
>This is part of a class that is used to insert in batch. I have a class InsertRow which is used to insert one record at a time into a table with all the data dictionary validations. But, sometimes, there could be a used to insert in batch thousands of records, where we do no need to validate against the data dictionary. In this case, I can call the InsertInRow class to insert thousdands of records in a flash.
>
>lnLoop was used to determine the number of loops as SQL Server can only insert in batch up to 1000 records at a time if I recall corrrectly. So, the part that negotiates with that is as follow:
>
>
>            ' If we have no record
>            If lnCount = 0 Then
>                Return True
>            End If
>
>            ' Get the number of loops
>            lnLoop = Int(lnCount / 1000)
>
>            ' If it is less than zero
>            If lnLoop = 0 Then
>                lnLoop = 1
>            End If
>
>            ' For each loop
>            For lnCounter = 1 To lnLoop
>
>                ' Get the start position
>                lnStart = (lnCounter * 1000) - 1000
>
>                ' Maximize to the number of records
>                lnMax = Math.Min(lnStart + 1000, lnCount)
>
>                ' Scan all records
>                For lnCounter2 = lnStart To lnMax - 1
>                    loRow = oDataProvider.oDataSet.Tables("Temp").Rows(lnCounter2)
>
Resolving loRow repeatedly in that last line looks a bit slow. Why not:
Dim rows as DataRowCollection = oDataProvider.oDataSet.Tables("Temp").Rows
For lnCounter2 = lnStart To lnMax - 1
       loRow = rows(lnCounter2)
Come to that why not allow a flexible batch size.Something like:
Public Sub ProcessAll(ByVal lnBatchSize As Integer)
        Dim i As Integer = 0
        Dim lnCount As Integer = oDataSet.Tables("Temp").Rows.Count
        While i < lnCount - lnBatchSize
            ProcessBatch(i, i + lnBatchSize - 1)
            i += lnBatchSize
        End While
        ProcessBatch(i, lnCount)
    End Sub
    Public Sub ProcessBatch(ByVal first As Integer, ByVal last As Integer)
        Dim loRow As DataRow
        Dim rows As DataRowCollection = oDataSet.Tables("Temp").Rows
        For lnCounter2 As Integer = first To last
            loRow = rows(lnCounter2)
        Next
    End Sub
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform