SqlDataReader ExecuteReader error

Posted on 2005-04-29
Last Modified: 2008-03-04
What in the heck am I doing wrong!  I am building a pocket pc application.  I have a form the consists of: ListBox1 and Button1.  I would like to fill the list box with the CompanyName values from the NorthWind database.  I will trigger the  ReadSqlDataReader in the click event of Button1.  I keep getting an error from the dr = cmd.ExecuteReader code.  I am using the 2002 emulator.  I have been at this for hours without any result.  I know my connection string is correct.  

    Public Sub ReadSqlDataReader()

        Dim cn As SqlClient.SqlConnection
        Dim cmd As SqlClient.SqlCommand
        Dim dr As SqlClient.SqlDataReader

            cn = New System.Data.SqlClient.SqlConnection("user id=sa;password=admin;database=Northwind;server=")
            cmd = New SqlClient.SqlCommand
            cmd.CommandText = "Select * from Customers"
            cmd.Connection = cn

            dr = cmd.ExecuteReader()

            While dr.Read()
            End While
        Catch ex As System.Data.SqlClient.SqlException
        End Try
    End Sub
Question by:CodeManiac
    1 Comment
    LVL 24

    Accepted Solution

    Open the connection

    cn = New System.Data.SqlClient.SqlConnection("user id=sa;password=admin;database=Northwind;server=")
    cmd = New SqlClient.SqlCommand

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Introduction When many people think of the WebBrowser ( control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    737 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

    21 Experts available now in Live!

    Get 1:1 Help Now