Groups | Blog | Home
all groups > dotnet ado.net > april 2008 >

dotnet ado.net : Add column using Dataset Designer => hosed project


Molon Labe
4/5/2008 12:36:01 PM
Context:

VS2008
SQL Server Compact 3.5 database

Problem:
I used the Dataset Designer to add a column to a table (right click on table
in designer, Add->Column).

How do I update the database to correspond with this change?

I tried locating the database in my Server Explorer and adding the identical
column by hand using the Table Properties.

Run the project and try to stuff some data in the newly modifed table...all
original columns get data but the new column only gets NULLs.

Try to use "Configure DataSet with Wizard" from Data Sources tab...get
warning that "The selected dataset contains objects that can only be viewed
with the Dataset Designer." Which I don't understand because I made what
seems a trivial modification to a table.

It seems there is no correspondence between the new column in the database
and the new column in the dataset. If I access the new column's DataColumn
properties in DataSet Designer, the entry for the "Source" property is empty,
and the dropdown selector only sees the original columns in the table, not
the new one.
Molon Labe
4/5/2008 12:57:00 PM
Followup:

Examining the auto generated code for the TableAdapter for the modifed
table, support for the new column is not included in, for example, the
InitAdapter method.

In general, if you make a change to a database schema, how do you get that
reflected within a project that currently uses the database? I'd like to just
delete the existing Data Source and add back the new one, but I don't see any
Molon Labe
4/5/2008 1:34:00 PM
Solution:

Here are the instructions for removing a data source from your project:

http://msdn2.microsoft.com/en-us/library/ms233820.aspx

I made a copy of my sdf file, deleted the database and xsd from Solution
Explorer, restored the copy, and added the data source back in. Had to
AddThis Social Bookmark Button