Click here to Skip to main content
16,019,876 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two tables

[Mobilization]-Primary key is [Fen_Inovoice_No] it is the forgien key is of [invovoice details]

[invovoice details] the primary keys are [Fen_Inovoice_No],[Item]

when I tried to view the data , the all data are not loading to listview why is that? only a one row is load


VB
private Sub viewItem1(ByVal invoice_no As String)

    myConnection = New SqlConnection(connectionstring)
    myConnection.Open()

    sqlcmd = New SqlCommand("SELECT Item,Quantity,Descrption ,Amount FROM [invovoice details] where  Fen_Inovoice_No='" & invoice_no & "'   ", myConnection)

    sqlcmd.ExecuteNonQuery()

    '    Dim dr As SqlDataReader = myCommand1.ExecuteReader
    Dim dr As SqlDataReader = sqlcmd.ExecuteReader

    dr.Read()
    ' pr = dr1("Category").ToString

    ''''''''''''''''''''''''
    ' For i = 0 To TempData.Rows.Count-1
    Dim newItem1 As New ListViewItem(dr.Item("Item").ToString)
    newItem1.SubItems.Add(dr("Descrption").ToString)
    newItem1.SubItems.Add(dr("Quantity"))
    newItem1.SubItems.Add(dr("Amount"))
    ListView1.Items.Add(newItem1)
    ' newItem.SubItems.Add()

    CalTotal()
    dr.Close()
    '''''''''''''''''''''''''''''
    myConnection.Close()

End Sub


Private Sub CalTotal()
    Dim TotalSum As Double = 0
    Dim TempNode As ListViewItem
    Dim TempDbl As Double
    For Each TempNode In ListView1.Items
        If Double.TryParse(TempNode.SubItems.Item(3).Text, TempDbl) Then

        End If
        TotalSum += TempDbl
    Next

    TextBox11.Text = TotalSum

End Sub
Posted
Updated 1-Sep-13 1:56am
v2

1 solution

i think u should put a code like this when a row to listview:
VB
while dr.read()
     Dim newItem1 As New ListViewItem(dr.Item("Item").ToString)
     newItem1.SubItems.Add(dr("Descrption").ToString)
     newItem1.SubItems.Add(dr("Quantity"))
     newItem1.SubItems.Add(dr("Amount"))
     ListView1.Items.Add(newItem1)

wend
 
Share this answer
 
v3
Comments
dili1234 1-Sep-13 12:12pm    
thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900