Solved databinding

Posted on 2005-04-14
Last Modified: 2010-04-23
I have this program I created using databindings.

I hate binding but for this application it is pretty small. ANyways I have 10 textboxes on form2

form1 comes up and asks user to pick a name. The user picks a name and then it calls form2 and grabs the data from the database and dumps into a dataset. This dataset is typed dataset... I then call my databinding like this

textbox1.DataBindings.Add("text", dataset1.tablename, "fieldname")

everything works fine, but then when I close form2 and then let the user select another name from form1. Form2 shows up blank. There is nothing being pulled in. Now I changed my dataset and data is being dumped into it successfully. Why is it showing the 1st time but not the second. Is there some type of databinding release I need to do????

Please help....
Question by:bman9111
    LVL 13

    Expert Comment

    Are you re-declaring your dataset before you use it again?

    If not you could use:

    LVL 8

    Author Comment

    got it, but Have no idea why it works

    if my form2_load I have the following code

     databaseconnection() 'this call the database
                commands= connections
                commands.CommandText = "select * from table1 where userinput= '" & combobox1.text & "'"
                dataadapter.SelectCommand = commands
                dataadapter.Fill(dataset1, "Table1")
            call populatetextboxes ' this is for the databindings

    I had to take the dataset1.table1.Rows.Clear()  out and put it into the form2_closing

    why, what is the difference if I call it before or after. I even wrote the  dataset1.table1.writexml to look to see if the data was going in and it was. So why does this fix my problem????
    Any ideas...
    LVL 13

    Accepted Solution

    You are clearing the dataset of any data that previosly existed, before you fill it with more data.

    So, to start off the dataset is empty.

    You call form2, and fill the dataset with data.

    User selects another name, which calls form2.

               Dataset already has data in it, and you try to fill the dataset with even more data.

               You empty all the data from the dataset.
               You fill the dataset with new data.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    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.
    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…

    754 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

    16 Experts available now in Live!

    Get 1:1 Help Now