Why am I getting System.Data.Common.DataRecordInternal on my drop down list>

Posted on 2012-08-15
Last Modified: 2012-08-15
Hi experts,
I'm trying to populate my drop down list internally in a couple different areas in my code and here is the code I'm using

Dim sconn As String
            sconn = System.Configuration.ConfigurationManager.ConnectionStrings("WebActivityConnectionString").ToString
            Dim myConnection As New SqlConnection
            myConnection.ConnectionString = sconn
            Dim myCommand As New SqlCommand
            myCommand.Connection = myConnection

                myCommand.Connection = myConnection
                myCommand.CommandText = "Select Statement_ID from Statement"
                myCommand.CommandType = CommandType.Text
                Dim reader As SqlDataReader = myCommand.ExecuteReader
                DDL_StatementID.DataSource = reader

When this happens all I get back are a bunch of System.Data.Common.DataRecordInternal?

Can anyone tell me what i'm doing wrong?
Question by:kpbarem
    LVL 83

    Accepted Solution

    Change your code to following

    Dim sconn As String = System.Configuration.ConfigurationManager.ConnectionStrings("WebActivityConnectionString").ToString
    Dim dbadp As New SqlDataAdapter("Select Statement_ID from Statement", sconn)
    Dim dTable As New DataTable
    DDL_StatementID.DisplayMember = "Statement_ID"
    DDL_StatementID.ValueMember = "Statement_ID"
    DDL_StatementID.DataSource = dTable

    Open in new window


    Author Comment

    You are awesome.  Thanks.  The only thing I found is that DDL_StatementID.DisplayMember and DDL_StatementID.ValueMember didn't work in my VBCode.

    I changed it to DDL_StatementID.DataTextField and DDL_StatementID.DataValueField.
    LVL 83

    Expert Comment

    Yup confused it with winforms :-)

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now