Link to home
Start Free TrialLog in
Avatar of codequest
codequest

asked on

Add/Change Column names

I started using a typed datatable.   Now, of course, I want to change a column name, and will want to add/delete columns going forward.   I see three steps:

A)  make the changes in the DB
B)  make the changes in the XML Schema for the typed data set
C)  make the changes in the code

What's the best approach for making the changes in the XML Schema?  Edit the schema directly?  Regenerate the table adapter?  Other?   Did I leave out something else important?

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of pbocanegra
pbocanegra

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of amyhxu
amyhxu

The table adapter will change the XML schema for you. Regenerating the table adapter should work, but you don't have to. You can go to the dataset designer (go to the DataSources tab and right click on the dataset you want to modify, choose "Edit DataSet with Designer"), then go to the tableadapter's property page where you can modify the SelectCommand's CommandText. Click on "..." and a Query Builder is opened where you can modify the columns. After you click OK on the Query Builder, it will prompt you whether you want to regenerate the UpdateCommand, click Yes and it's done automatically for you.
Avatar of codequest

ASKER

Thanks for the input.   In this case I'm not defining the dataadapter on a page...I'm using a dataset item in App_Code.  However, because of your message, I guessed that it wasn't that tricky, so I:

> deleted the table in the dataset designer,
>  changed the DB definition (SQL Server Express)
> dragged the table from the DB back into the designer
> selected configure on the table in the designer (right click) and made some adjustments
> completed configuration
> updated the vb field calls

and it worked on the first try.

Next time maybe I'll look for a way to update it without the delete and re-add.

Thanks for the prompt...that's what did it.

While you are on the dataset designer, you could also right click on the datatable name and choose "Configure...". This will open the TableAdapter Configuration Wizard where you can edit the query.
You mentioned table adapter in your question, which made me think that you are using VB2005, LOL. Anyway, when you upgrade to 2005, that's the step you can use.
amyhxu:  thanks for the response...I saw it too late.  Please look for question "amyhxu  Q_21798590 additional points" for additional points...I'll accept a response from you there.