After creating a datasource and generating a dataset, my database has changed.
How can I "refresh" the dataset so it sees these changes.

One Method I have been able to do is delete the .xsd file from soultion explorer. There go my modified queries & code.

Another method tried was to re-drag/drop the table from Server Explorer to the DataSet design surface. However, it creates another instance of the table.
For example, if my table is named tbl_test, when I drop re-drop tbl_test on the surface, I now have another table talled tbl_test1

I don't want to delete the original tbl_test first, as I have modified the queries and code for it.

Am I missing something?

Is there a better way?

Thanks

Dani AI

Generated

A short, practical summary and safe workflow for this VS2008 / typed-DataSet situation. The .xsd is the dataset schema (it drives the generated designer code), so never treat deleting the .xsd as a routine step—keep the .xsd and its generated designer under source control and keep a quick text backup of any custom SQL or Add Query results before touching the designer. (learn.microsoft.com)

Non‑destructive options that preserve custom queries and adapters:

  • Add new columns to the DataTable schema rather than re-creating the adapter. The DataSet Designer allows adding columns (DataTable -> Add -> Column) so the schema grows without re-writing adapter methods. If direct XML editing is needed, edit the .xsd with the XML editor and then regenerate the designer code by using “Run Custom Tool” on the .xsd. If the TableAdapter’s Select is changed by the wizard it will pick up new fields but may also replace generated adapter commands, so keep backups of any hand‑tuned SQL before running the wizard. (learn.microsoft.com)

A durable way to keep custom logic safe is to move runtime code out of the generated file and into partial classes or stored procedures. TableAdapters and their generated classes are partial, so custom methods can live in a separate source file and will not be overwritten by regeneration. A short VB.NET sketch that belongs in a new file (not the designer file) shows the pattern:

Namespace MyDataSetTableAdapters
    Partial Public Class tbl_testTableAdapter
        Public Function GetCustomByStatus(status As String) As MyDataSet.tbl_testDataTable
            ' Custom implementation here — stays separate from generated code
        End Function
    End Class
End Namespace

Extending via partial classes and using stored procedures for non‑standard queries are common approaches to avoid losing manual changes; TableAdapter query methods and stored‑procedure support are exposed by the dataset tools. For one‑off merges, dragging the table to create a second adapter and then carefully copying query nodes between the two .xsd entries (or copying SQL text from backups) is a workable fallback—but only after backing up the .xsd and regenerating the designer with “Run Custom Tool.” (devblogs.microsoft.com)

This guidance ties together ’s observation (the wizard will detect new columns) and ’s experience (custom queries can be clobbered), while offering non‑destructive alternatives and a recommended pattern (partial classes / stored procs + source control) for longer‑term maintenance.

Recommended Answers

All 3 Replies

Right click on the table adapter and configure the queries. Step through the wizard and let it pull down the new results and it will adjust the dataset for you accordingly. If you added new columns but don't have the new columns in your SELECT statement then obviously it will not be aware of the schema changes and the new data won't be pulled in.

OK, I tested that and it did "see" newly added columns.
However, any customizations I made to the queries previously would be lost. I guess there is now way around that.

Thanks for your quick reply.

No, there is no way around that. This is one of the many reasons why I don't use datasets :)

Please mark this thread as solved if I have answered your question and good luck!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.