I'm trying to teach myself VB.NET and having some troubles right now... please help me out :sad:
I'm working with NorthWind database in MS SQL Server.
I suppose I'm trying to populate tables into ListBoxes and the following highlighted lines are giving me an error (Value of type '1-dimensional array of System.Data.DataRow' cannot be converted to 'System.Data.DataRow'.)
Everything else seems OK except that line..
Please help..

[LEFT]Imports System.Data.SqlClient
Public Class frmCustomers
    Inherits System.Windows.Forms.Form
    Protected dsCustomers As DataSet
'-- Windows Form Designer Generated code toggled
Public Sub btnPopulate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPopulate.Click
        lblStatus.Text = "Please wait ..."
Dim cnWind As New SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=NorthWind")
Dim daCustomers As New SqlDataAdapter("SELECT CustomerID, CompanyName FROM Customers", cnWind)
        Dim daOrders As New SqlDataAdapter("SELECT OrderID, OrderDate, CustomerID, EmployeeID FROM Orders", cnWind)
        Dim daEmployees As New SqlDataAdapter("SELECT EmployeeID, LastName, FirstName FROM Employees", cnWind)
dsCustomers = New DataSet("Customers")
        daCustomers.Fill(dsCustomers, "Customers")
        Dim dtCustomers As DataTable = dsCustomers.Tables("Customers")
        daOrders.Fill(dsCustomers, "Orders")
        Dim dtOrders As DataTable = dsCustomers.Tables("Orders")
        daEmployees.Fill(dsCustomers, "Employees")
dsCustomers.Relations.Add("CustomerOrders", _
            New DataColumn() {dtCustomers.Columns("CustomerID")}, New DataColumn() {dtOrders.Columns("CustomerID")})
Dim dr As DataRow
        For Each dr In dtCustomers.Rows
            lstCustomers.Items.Add(dr.Item("CustomerID").ToString() & " --- " & dr.Item("CompanyName").ToString())
        lblStatus.Text = "Data Retrieved"
    End Sub
Private Sub lstCustomers_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lstCustomers.SelectedIndexChanged
Dim parentRow As DataRow = dsCustomers.Tables("Customers").Select( _
        "CustomerID = '" & lstCustomers.SelectedItem.ToString().Substring(0, 5) & "'")(0)
[B]Dim childRows As DataRow = parentRow.GetChildRows( _[/B]
[B]          dsCustomers.Relations("CustomerOrders"))[/B]
Dim dr As DataRow
        For Each dr In childRows
            Dim drEmp As DataRow = dsCustomers.Tables("Employees").Select( _
                "EmployeeID = '" & dr.Item("EmployeeID").ToString() & "'")(0)
            lstOrders.Items.Add(dr.Item("OrderID").ToString() & " - " & _
                dr.Item("OrderDate").ToLongDateString() & " - " & _
                drEmp.Item("FirstName").ToString() & " " & _
    End Sub
End Class


dang.. it was nothing but a simple ()..
how do i delete this thread??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.