DataSet Editor - migrating DB changes to a Typed DataSet - a Re-Sync button maybe??

D

Dotnet Gruven

Is there a trick to keeping a Typed DataSet in sync with the underlying
database other than either manually making the changes or deleting and
adding the table back?

For example, I've created a Typed DataSet with about 10 tables, each table
has between 1 and 10 TableAdapters.

Now, weeks later, a column is added to one of the corresponding tables in
the database.

How does that column get to the DataSet??

TIA,
geo

PS. I've posted this on vstudio.development, but that appears to be the
wrong newsgroup.
 
K

Kevin Yu [MSFT]

Hi geo,

As far as I know, the DataTable in the typed DataSet doesn't sync
automatically with the underlying database. However, you can try to
re-configure it and refresh the DataSet with the following steps:

1. Right click on the TableAdapter in typed DataSet, select Configure....
from the popup menu.
2. Make sure you have check Refresh DataTable in the Advanced Options
setting and click Next to go through the wizard.
3. This DataTable will be refreshed.

This might not be a grace workaround, but it seems to be the most simple
way.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
D

Dotnet Gruven

Perhaps I wasn't clear in asking my question Kevin:

Your reply below will refresh the table, but only the data, not the schema.
I went to Advanced Options Dialog Box as you suggested and the Refresh the
data table option says it "Adds a Select statement after Insert and Update
statements to retrieve identity column values, default values, and other
values calculated by the database.

What I am looking for is a procedure that allows a change to the schema of a
table in a database to get to the typed dataSet table without having to
remove and then re-add the table. The problem is, there are TableAdapters
that then have to be recreated in the newly added table.

Here are the steps I am currently using... (example, add a column to MyTable
called IsActive a bit field)

1) In SQL Server management Studio and Modify MyTable adding column
IsActive, Data Type bit, allow nulls true
2) In Visual Studio, go to the XSD file, drag the updated table MyTable onto
the design surface.
3) Visual Studio will give it a name like MyTable1
4) For each TableAdapter in the original Mytable, create a new one in
MyTable1.
5) Modify each select statement template to perform the function of the one
back in MyTable, taking into account the new Column IsActive
6) Rename MyTable to MyTableOld
7) rename MyTable1 to MyTable
8) Add IsActive to any Update or Insert methods used on any of the
TableAdapters
9) Rebuild and rerun all tests

Is there an easier way to do this? It is a tedious and error prone process,
but I guess this all goes to show, each hour of upfront design saves hours
in development time. Unfortunately, the reality is a designer cannot
foresee all eventualities, marketeers don't always ask for all features
until 10 minutes before ship time and then, there is always the next
version.

Looking at the generated XML behind the design surface (right click, choose
code), it looks like another possiblity is cut and paste XML, but I'd rather
not go there.

Anyway, if anyone can suggest a better process, I'm all ears.... Otherwise,
I'll look forward to this feature in VS.NET 2008 or so! :*)

TIA,
Geo
 
K

Kevin Yu [MSFT]

Hi Geo,

Sorry for the misunderstanding. Now I know that you need to update the
schema. However, there isn't an elegant way to refresh the schema when data
source schema changes.

If the table is generated with the TableAdapter configuration wizard, and
you're using SELECT * FROM statement, you can simply re-configure the
TableAdapter and go through the wizard again, the changes will be reflected
in the schema. It works fine on my machine. But if it is not the case, for
example, you're not using the SELECT * FROM, you have to add the column
name manually.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top