Add column using Dataset Designer => hosed project

M

Molon Labe

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.
 
M

Molon Labe

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
way to delete DataSets from the Data Source panel.
 
M

Molon Labe

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
restore table relations in Dataset Designer, but otherwise worked fine.
 

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