954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Adding columns existing table

Hi,

Can anybody give an example of adding columns to an already populated dataset/datatable and reflecting changes to an already populated datagridview so that I can modify/added the row and use dataadapter.update to change the datasource.

Thanks
snky

snakay
Junior Poster in Training
79 posts since May 2009
Reputation Points: 4
Solved Threads: 0
 

You need to change the DataAdapter's update, delete, insert, and select queries and add another parameter for the new field. This is probably not a good idea.

Let me ask you this -- are you using a typed dataset or one created in code?

sknake
Industrious Poster
4,954 posts since Feb 2009
Reputation Points: 1,764
Solved Threads: 735
 

I use created in code, in memory.

Update/Delete working fine, because I don't have to add any column or so on those. Whereas I have to add number of columns to the already populated datatable and insert them all as new (RowStateAdded). It inserts only the ones which have already been populated. My ınsert statement includes the newly defined columns. Apparently I fail to define new columns and attach them somehow to datatable. I have tried many possibilities but no result
thanks,

snakay
Junior Poster in Training
79 posts since May 2009
Reputation Points: 4
Solved Threads: 0
 

I think I solved it, it is uppercase/lowercase problem. When I define the new columns I defined them lowercase whereas in insertcommand they are uppercase. So newly added columns also inserted into datasource.

Those concepts however did not settle very clear in my mind

1- when I adapter.Update the datasource fields have to be uppercase, otherwise it does not work. Is there a parameter I have to define so that it accepts anything(upper or lowercase)

2- how do I reflect changes to datagridview after I add columns and enter values into them

3- If I enter values to the grid where those additional columns already defined in the formDesigner but not in the datatable, how can I reflect datagirdview to datatable

4- how should I use binding, beginedit and endedit in these cases
thanks,
snky

snakay
Junior Poster in Training
79 posts since May 2009
Reputation Points: 4
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: