how do i populate a text box from a dataset and bind the text box to the dataset

Posted on 2006-04-21
Last Modified: 2010-05-18
i am trying to populate a dataset with a stored procedure that will fill a group of controls on a form such as textboxes and combo boxes.
the problem i am having is that i cannot figure out the syntax to populate the text boxes with the fields required and bind the textboxes to the dataset. i am also going need navigation controls to sift through the records the the query returns. any help or code examples would be great


Question by:mackie1908
    LVL 6

    Assisted Solution

    LVL 6

    Accepted Solution


    Sample Chapter 10 ADO.NET Data-Binding in Windows Forms

    LVL 6

    Expert Comment


    Author Comment

    guys i have managed to bind the control with your help but i am now getting a new error.  below is the sub taht is populating the textboxes in the form. but now i am getting a new error "cannot bind to property or column location on datasource. " could someone please help me with what i am doing wrong.

     Private Sub QueryByLocation2(ByVal cn As SqlConnection)
            Dim cmd As New SqlCommand
            Dim da As SqlDataAdapter
            Dim ds As New DataSet
            Dim newBinding As System.Windows.Forms.Binding

            newBinding = New System.Windows.Forms.Binding("Text", ds, "Location")

            cmd = cn.CreateCommand
            cmd.CommandText = CommandType.StoredProcedure
            cmd.CommandText = "QueryByLocation '" & LocationName.Text & "'"

            da = New SqlDataAdapter(cmd)


            cmd = Nothing
            da = Nothing
            ds = Nothing
        End Sub

    Author Comment

    sorry needed to add if i the Locations.Location (which is my table name) to my databinding i get an error saying "cannot create a child list for field locations" how do i get around either problem to get the data into my text box

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    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 (…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    760 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

    8 Experts available now in Live!

    Get 1:1 Help Now