Results 1 to 2 of 2

Thread: Data row

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Location
    dallas,texasd
    Posts
    26

    Data row

    Would someone please point out my problem here, and supply the correct code.

    =============I think i messed up around the for each statement================

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Dim cnn As New SqlConnection("Data Source=DESKTOP; Initial Catalog=Northwind; Trusted_Connection=yes")
    cnn.Open()
    Dim da As New SqlDataAdapter("Select * From Customers", cnn)

    Dim ds As New DataSet
    da.Fill(ds, "Customers")

    Dim dr As DataRow

    For Each dr In ds.Tables.Item("Customers").Rows

    ListBox1.DataSource = dr
    ListBox1.DataBind()

    Next

    End Sub

    End Class

  2. #2
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    Re: Data row

    well you are rebinding the one list for each data row. That effectively clears what just went in and repopulates the list with the data in the current row. Giving you whatever is in the last row.

    try setting the data table as the data source and setting display and value members to the column you want there.
    Magiaus

    If I helped give me some points.

Posting Permissions

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



Click Here to Expand Forum to Full Width