Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27353

VS 2010 Adding sum Result beneath the column(SQL)

$
0
0
Hi I want the sum of the column(Esicemployeeshare) exactly beneath the column(Esicemployeeshare)How can I do that
here is my code
Code:

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Me.ListView1.View = View.Details
        Me.ListView1.GridLines = True
        'conn = New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=pay;")
        conn = New SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Danial\documents\visual studio 2010\Projects\ESI_PF_Payroll_V1\ESI_PF_Payroll_V1\Pay.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")
        Dim strQ As String = String.Empty
        Dim strQ1 As String = String.Empty
        strQ = "SELECT firstname,lastname,Esicemployeeshare FROM ESIC "
       
       
        cmd = New SqlCommand(strQ, conn)
       
        da = New SqlDataAdapter(cmd)
        ds = New DataSet
        conn.Open()
        da.Fill(ds, "Tables")
        Dim i As Integer = 0
        Dim j As Integer = 0
       
        conn.Close()
       
        '//////////////////////////////////////////////////////////////////
        For i = 0 To ds.Tables(0).Columns.Count - 1
            Me.ListView1.Columns.Add(ds.Tables(0).Columns(i).ColumnName.ToString())
        Next
        'Now adding the Items in Listview
        Me.ListView1.Columns.Add("Question")
       
        For i = 0 To ds.Tables(0).Rows.Count - 1
            For j = 0 To ds.Tables(0).Columns.Count - 1
                itemcoll(j) = ds.Tables(0).Rows(i)(j).ToString()
            Next
            Dim lvi As New ListViewItem(itemcoll)
            Me.ListView1.Items.Add(lvi)
        Next
        Me.ListView1.Items.Add(String.Empty)
        Me.ListView1.Items.Add("Totall: ")
        '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    End Sub


Viewing all articles
Browse latest Browse all 27353

Trending Articles