[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2012-08-15
3
Medium Priority
?
1,773 Views
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

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


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

Can anyone tell me what i'm doing wrong?
0
Comment
Question by:kpbarem
  • 2
3 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 38297554
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
dbadp.Fill(dTable)
dbadp.Dispose
DDL_StatementID.DisplayMember = "Statement_ID"
DDL_StatementID.ValueMember = "Statement_ID"
DDL_StatementID.DataSource = dTable
DDL_StatementID.DataBind()

Open in new window

0
 

Author Comment

by:kpbarem
ID: 38297677
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.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38297737
Yup confused it with winforms :-)
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Loops Section Overview
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month20 days, 2 hours left to enroll

872 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