views:

54

answers:

3

hi every one nice job is it possible to update a data base which doesn't have primary key column with a datagridview?(in a winform program) i use sql express 2008,and wanna do this with dataset approach. Cheers

A: 

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.

Maxim Gershkovich
pay attention my friends,in a winform app i have used a datagridview related to a table of some db.in this dgv,user can add or delete rows,or just modify one cell,then push a button that will update the underlying db.some information have filled the dgv and the user can modify this filled dgvunderlying db has not a column set to be as a pk,it means all columns can be modified.i used sqlcommandbuilder but it says select command should return a column that is pk.
Saeidmscs
A: 

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.

Yves M.
A: 

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.

nyn3x