update(reload) the windowsform

johmolan

Well-known member
Joined
Oct 11, 2008
Messages
129
Programming Experience
Beginner
I have a problem where I don't seem to find a solution.

I have a windowsform with some datagrids and textboxes.

Both tekxtboxes and datagrid have the same sources.

I edit some data in my database and save them, when I then use the commands:
VB.NET:
Me.SpørringSluttdokTableAdapter.Fill(Me.Database4DataSet1.SpørringSluttdok)
I update my database with the new data, then the new data is vivible in my grid. But how do I update the textboxes? Is there a fast way to reload the form to get the new data visible?
 
If the grid and the TextBoxes have the same data source then updating one will update the other. That's the whole point of data-binding. If changing one didn't affect the other then they would be bound. You're going to ahve to describe your situation in more detail. Be specific.
 
Ok, I load an xml file into my dataset by using the method

Database4DataSet1.ReadXml(fileName:="c:\test2.xml")

But I can't update my database.

I have tried several methods like

Tableadaptermanager,updateall(Database4DataSet1)
But I get an errer but I do not understand why.

Is this the right way to update my database or is there another way?
 
Right now it doesnt sound like you have a database at all --> youre reading from an XML file which is not a database
 
I do have an access database conncted to the database, but I want to be able to read from the xml file and update the database with the data in the xml file.
 
And your dataset, read from your XML file, has some datatables that have changed rows, yes?

if YourDataSet.HasChanges = False, then you wont update the database


-

Now to explain what jmc said, you dont need to Fill (download) from database after you Update (upload) to a database, because Update is a SYNCRONIZING operation. It makes the data in the DB the same as the data you see.

If youre having trouble understanding this, let me give an analogy:

You open a Word document (fill a datatable)
You edit the document (make changes to the table)
You press Save icon (you call Update() on the tableadapter)

Do you now close and reopen the word document to see your changes? No.. So you don't FIll() after Update()!


As an aside, please read the DNU link in my signature. It shows a common trap people fall into with file based databases
 

Latest posts

Back
Top