Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Location
    England
    Posts
    132
    Thanks
    24
    Thanked 0 Times in 0 Posts

    Question Visual Web Developer 2008 - Hot To Show Total Of Column After Running A Query?

    I've connected my sql database to VWD 2008 and have added a select where query. One of the columns shows a fee. I want a small label under the column to show the total of those feels but I don't want to add a column in the database itself. How do I do this?

    http://soccer-europe.com/Transfers/W...Search_001.png

  • #2
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,758
    Thanks
    41
    Thanked 191 Times in 190 Posts
    during your post-back calculate your total and store it as a variable and populate an object with it

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #3
    Regular Coder
    Join Date
    Jul 2007
    Location
    England
    Posts
    132
    Thanks
    24
    Thanked 0 Times in 0 Posts
    I just started using VWD yesterday so I have no idea how to do that.

  • #4
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,758
    Thanks
    41
    Thanked 191 Times in 190 Posts
    what is VWD?
    what language are you using?

    scratch that i googled it- from my understanding its visual studio light- what language are you using?
    Last edited by alykins; 04-11-2012 at 12:59 AM.

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #5
    Regular Coder
    Join Date
    Jul 2007
    Location
    England
    Posts
    132
    Thanks
    24
    Thanked 0 Times in 0 Posts
    Visual Web Developer 2008, similar to Visual Studio. It uses aspx. It's driven by toolbars and wizards.

  • #6
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,758
    Thanks
    41
    Thanked 191 Times in 190 Posts
    the simple answer is bind a label to it- but since you are using toolbars and wizards i have no clue what kind of interface you have available- can you access the code behind? you need to do some calculation somewhere and then fill a label

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #7
    Regular Coder
    Join Date
    Jul 2007
    Location
    England
    Posts
    132
    Thanks
    24
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by alykins View Post
    the simple answer is bind a label to it- but since you are using toolbars and wizards i have no clue what kind of interface you have available- can you access the code behind? you need to do some calculation somewhere and then fill a label
    Hi

    Yes I can view the code. I can add a label but I don't understand how to perform a caculation on the query itself. Here's the datasource if it helps?

    Code:
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:TransfersConnectionString %>" 
            SelectCommand="SELECT [Player], [Position], [Previous Club] AS Previous_Club, [Transfer Fee] AS Transfer_Fee, [New Club] AS New_Club, [Type], [League], [Window] FROM [Summer_2001_2011] WHERE ([Player] = @Player)">
            <SelectParameters>
                <asp:ControlParameter ControlID="player" Name="Player" PropertyName="Text" 
                    Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>

  • #8
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,758
    Thanks
    41
    Thanked 191 Times in 190 Posts
    Quote Originally Posted by alykins View Post
    what is VWD?
    what language are you using?

    scratch that i googled it- from my understanding its visual studio light- what language are you using?

    ..... what.... language.... are.... you.... using?!
    asp and aspx are not languages asp is typically vbscript and aspx is typically vb or C# of the three I know vb and C# extensively (sorry can't help vbs) so again- what language are you using?

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #9
    Regular Coder
    Join Date
    Jul 2007
    Location
    England
    Posts
    132
    Thanks
    24
    Thanked 0 Times in 0 Posts
    Visual Basic. There's also an option to use Visual C#.

  • #10
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,758
    Thanks
    41
    Thanked 191 Times in 190 Posts
    Code:
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    
            Dim cnstr As String = "demo connection string"
            Dim Query As String = "select * from table"
            Dim tmptbl As New DataTable
    
            Dim conn As New SqlConnection(cnstr)
            Using conn
                conn.Open()
                Dim cmd As New SqlCommand(Query, conn)
                cmd.CommandType = CommandType.Text
                Using cmd
                    Dim dr As SqlDataReader = cmd.ExecuteReader
                    tmptbl.Load(dr)
                End Using
                conn.Close()
            End Using
    
            Dim number As Integer = calc(tmptbl.Rows(0)(0).ToString, tmptbl.Rows(1)(1).ToString)
            Label1.Text = number.ToString
        End Sub
    
        Private Function calc(ByVal s1 As String, ByVal s2 As String) As Integer
            Dim i As Integer = Integer.Parse(s1)
            Dim j As Integer = Integer.Parse(s2)
            Dim total As Integer
    
            'do some math function...
    
            Return total
        End Function
    should be enough to get you started- you will need to figure out how to get you index- follow the link in my sig for the msdn class lib... also most searches with the key words of class C# or VB will hit the msdn lib as top hit

    note- this is a windows form- quicker to make a sln as form, but concept is the same... attach that process to a page load or a button click or whatever

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • Users who have thanked alykins for this post:

    Mehdi72 (04-11-2012)


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •