开发者

How to update the Dataset to reflect an added column in the data source without deleting the adapter?

I've made a dataset using the dataset designer, and I'm trying to add a column to reflect changes made to the database (added a column, nothing fancy). Is there a way to 'refr开发者_运维问答esh' the dataset schema from the datasource without deleting my adapter (and all the methods and queries I've created)?


I know its been a while since you posted but as I was having the same problem and figured out how to do this I reckoned I'll post the solution that worked for me.

  1. Right click on the dataset object you want to update (on the strip at the bottom of your viewpane)

  2. Select "Edit in Dataset Designer"

  3. in the dataset designer, right click on the header of the table you want to add a column to

  4. select configure... this will bring up the sql statement that is used to draw values into the dataset for this table

  5. Edit the sql to include the column you want to include in your dataset's table and click finish i.e. in the select statement, include your columns name in the list

  6. close the dataset designer then go to any controls (in my case its a datagridview), click on the tasks arrow (top right hand corner next to the handle) and select add column

  7. select the newly created column from the list of databound columns and click "add"

  8. select "edit columns" from the task menu

  9. move the column to the correct position (it will always be placed as the last column in your grid and you may not want it to be the last column)

voila, I know its hardly snappy but it beats the hell out of deleting the dataset and then fixing up all the coding errors that come up... also after doing it a few times it'll be like second nature (I hope)

regards

p.s. am working in VS2010


Had to just delete the adapter and the table. It's rather annoying but I guess there really isn't a way around it. Maybe in VS2010 or later versions of .net.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜