Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting access to a SUM column from the SQL
Message
From
14/06/2006 11:41:46
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01128850
Message ID:
01129047
Views:
18
>What if you cast/convert the sum column in your query to int:
>
>SELECT CAST(SUM(NewAccount) AS INT) AS SumColumn FROM Monthly
>or
>SELECT CONVERT(INT, SUM(NewAccount)) AS SumColumn FROM Monthly
>
>It may be that the server is creating a column of a different data type.

I need a double. I adjusted to call my own function to handle the formatting. This has resolved the issue.

I am using something like this:
                        If Not loDataProviderTotal.SQLExec("SELECT SUM(" + aField(lnCounter, 1) + _
                         ") AS SumColumn FROM " + cAlias, cConnectionString) Then
                            cHtml = oApp.cError
                            Return False
                        End If

                        loRowTotal = loDataProviderTotal.oDataView(0).Row
                        MessageBox.Show(oApp.GetFormatValue(loRowTotal("SumColumn") , 2))
        ' Format a value
        ' expC1 Separator
        ' expN2 Number of decimals
        Public Function GetFormat(ByVal tcSeparator As String, ByVal tnDecimal As Integer) As String
            Dim lcFormat As String = ""
            Dim lnCounter As Integer = 0

            ' Obtain formatted value
            lcFormat = ""
            For lnCounter = 1 To 9
                lcFormat = "#" + lcFormat
                If lnCounter Mod 3 = 0 Then
                    lcFormat = tcSeparator + lcFormat
                End If
            Next
            lcFormat = lcFormat + "0"

            ' If we have decimals
            If tnDecimal > 0 Then
                lcFormat = lcFormat + "." + "".PadRight(tnDecimal, "0")
            End If

            Return lcFormat
        End Function

        ' Format a value
        ' expN1 Value
        ' expC1 Separator
        ' expN2 Number of decimals
        Public Function GetFormatValue(ByVal tnValue As Double, ByVal tcSeparator As String, _
         ByVal tnDecimal As Integer) As String
            Dim lcFormat As String = ""
            Dim lcValue As String = ""
            lcFormat = oApp.GetFormat(tcSeparator, tnDecimal)
            lcValue = Format(tnValue, lcFormat)
            Return lcValue
        End Function
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
Previous
Reply
Map
View

Click here to load this message in the networking platform