Link to home
Start Free TrialLog in
Avatar of Winston Smith
Winston SmithFlag for Canada

asked on

Why do i get this value returned

Hi All.
Programming in VS.NET using VB.NET Windows Forms

Have the following code on a combobox (call it the parent)
Private Sub adRE_cmbRaceName_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles adRE_cmbRaceName.SelectedIndexChanged

        LoadDate()

    End Sub

it calls this function to load the 'child' combobox with values from the DB


Private Function LoadDate() As Integer
        Dim myDS As New DataSet
        Dim cnn As SqlConnection = New SqlConnection(ClientConnString)
        Dim myCommand As SqlCommand = New SqlCommand("Select RaceDate from race_event where RaceID = " & adRE_cmbRaceName.SelectedValue, cnn)
        myCommand.CommandType = CommandType.Text
        cnn.Open()

        Dim myDataAdapter As SqlDataAdapter = New SqlDataAdapter(myCommand)
        Try
            myDataAdapter.Fill(myDS, "Date")
        Catch
            MsgBox("Error updating database. Error number: " & Err.Number & ": Description: " & Err.Description, MsgBoxStyle.Exclamation, "Database Error")
        End Try

        cnn.Close()

        adRE_cmbRaceDate.DataSource = myDS.Tables(0)
        adRE_cmbRaceDate.DisplayMember = "RaceDate"

    End Function

All code works fine but everytime the child combobox is filled with the following text only, 'System.Data.DataRowView'.
Then i move the parent again, it fires the code, and i get the values i want in the child. This happens on all my combo boxes i do on a selectediindexchange trigger so hopefully someone has seen this before as i am pulling my hair out. Won't do to have to tell the user to 'Just twiddle with the drop-downs until the values come out' LOL.

Thanks everyone!!





ASKER CERTIFIED SOLUTION
Avatar of khan_zahid20
khan_zahid20

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial