hamed
hamed

Reputation: 137

updating dataset when adding a new field in database in c#

I have made a database and created a table with five fields and used add new datasource and added a new dataset by using that. And I have made a form and inserted all fields by dragging them into the form and changed lots of the properties. Now I need to add a new field into the table in database. Do I have to create a new datasource and a new dataset and do everything from beginning or there is a way to update the datasource and dataset so that the new field automatically appears in them? Any answer would be appreciated.

Upvotes: 3

Views: 12531

Answers (1)

faby
faby

Reputation: 7558

As you can read here you should right-click the TableAdapter in the Dataset Designer and click 'Configure' the TableAdapter Configuration Wizard opens where you can reconfigure the main query that defines the schema of your table. This should leave the additional TableAdapter queries (the additional methods) that were added after initial configuration.

So follow these steps

  1. Open you xsd file.
  2. Right click on Fill,GetData -> Configure
  3. Click Query builder and add the new column in the query statment
  4. Click ok and then your dataset is updated with the new database structure

If it doesn't work try deleting the dataTable and drag your table from Server Explorer again in your xsd file

Upvotes: 5

Related Questions