We help IT Professionals succeed at work.

Add/Change Column names

codequest
codequest asked
on
Medium Priority
2,378 Views
Last Modified: 2010-05-18
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!
Comment
Watch Question

IN the .vb page change the dataadapter in the property "SelectCommand" with the new columns, and then press in the bottom "Generate Dataset". VB.Net automatically generate the new xml schema.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Commented:
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.

Author

Commented:
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.

Commented:
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.

Commented:
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.

Author

Commented:
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.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.