开发者

update a database that has not a PK column

nice job is it possible to update a data base which doesn't have primary key column with a datagridview?(in a winf开发者_JAVA技巧orm program) i use sql express 2008,and wanna do this with dataset approach. Cheers


Without knowing a significant amount about what exactly you are doing and how you are going about your problem the simple answer is. Yes…

The datagridview in the .Net framework allows for binding to Objects exposing public properties and implementing custom select and update methods. Therefore it allows you to implement your own custom update method if required and allows for you to perform the update based on any column in your underlying database.


You still need a unique column or a combination of columns to differenciate the various rows you are about to update. At the end of the day the DataLayer that is used to access the data will just do an ordinary sql update/insert on your data. Just to have asked you but your data model seems kind of broken. I mean that a primary key or at least a unique column would be preferable in any case.


It's all about where your data is actually coming from, whether it's using datasets with plain-old-sql, some kind of ORM (NHibernate or Entity-Framework or whatever), typed datasets, linq-2-sql ...

Depending on your datasource you might have to introduce a primary key to your database.

The GridView actually doesn't care about that, in the end it's just displaying a list of data, and to the grid there is no such thing as a primary key. This only matters to the data access technique in order to know which row to update.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜