Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • 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....
0
bman9111
Asked:
bman9111
  • 2
1 Solution
 
TorrwinCommented:
Are you re-declaring your dataset before you use it again?

If not you could use:

Dataset.Clear
Dataset.Dispose
0
 
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
       Application.DoEvents()
            dataset1.table1.Rows.Clear()
            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...
0
 
TorrwinCommented:
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.

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

     NOW:
           You empty all the data from the dataset.
           You fill the dataset with new data.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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