PC Review


Reply
Thread Tools Rate Thread

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

 
 
Dotnet Gruven
Guest
Posts: n/a
 
      14th Dec 2005
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.


 
Reply With Quote
 
 
 
 
Kevin Yu [MSFT]
Guest
Posts: n/a
 
      15th Dec 2005
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."

 
Reply With Quote
 
Dotnet Gruven
Guest
Posts: n/a
 
      18th Dec 2005
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

"Kevin Yu [MSFT]" <v-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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."
>



 
Reply With Quote
 
Kevin Yu [MSFT]
Guest
Posts: n/a
 
      20th Dec 2005
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."

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to cast object of type 'System.Data.DataSet' to Typed DataSet Optimus Microsoft VB .NET 1 31st Jan 2006 06:26 AM
Ccopying a datatable content from an untyped dataset into a table which is inside a typed dataset Nedu N Microsoft ADO .NET 7 9th Dec 2003 02:50 PM
copying a datatable content from an untyped dataset into a table which is inside a typed dataset Nedu N Microsoft ASP .NET 2 31st Oct 2003 01:05 PM
Ccopying a datatable content from an untyped dataset into a table which is inside a typed dataset Nedu N Microsoft ASP .NET 2 31st Oct 2003 02:42 AM
Cast weakly typed DataSet to a strongly typed dataset??? Microsoft Dot NET 0 18th Sep 2003 10:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:58 AM.