• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 371
  • Last Modified:

vb.net databinding

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....
  • 2
1 Solution
Are you re-declaring your dataset before you use it again?

If not you could use:

bman9111Author Commented:
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...
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now