views:

1468

answers:

3

Hi,

I using the Ultrawebgrid- Update event::

protected void UltraWebGrid1_UpdateRow(object sender, RowEventArgs e)

so, I want to update the row(updated in the grid) in the datatable (inside a dataset)

The datatable doesn't hav any primary key too.. How can i find any row in such datatable?

for e.g. i can go for

UltraGridRow oldrow = (UltraGridRow) e.Data;

now, how can i find the row (in the datatable inside a dataset) which is same as the oldrow so that i can update it in the dataset?

The datatable does not have any primary key

+1  A: 

You need to have some way to uniquely identify a row in the database table. Normally, a database table will have a field or fields that serve this purpose by acting as a primary key. From what you are saying, it sounds like the table doesn't have a primary key. Nevertheless, there needs to be some combination of data that can be used to act like a primary key.

For example, the table might hold user information, and by combining hair colour, height, weight, address and age this could be sufficient to uniquely identify a user. Why you would want to do this is a little confusing to me, but we can assume you have a good reason for wanting to do this. Having formulated this combination, you need to put those guys into the where clause of your SQL UPDATE statement to identify the row you want to update:

UPDATE TABLE_WITH_NO_PRIMARY_KEY SET NAME = 'Bobby Tables'
  WHERE HAIR_COLOUR = 'RED' AND HEIGHT = '215' AND SO ON

The risk with doing this is you may run into a situation where more than one user have the same identifying features (maybe they are twins?) so the update statement will update both rows instead of only one.

1800 INFORMATION
+1. The exact selection criterium is known, as the entire old row is available. You simply use one WHERE clause per field in the row. Probably redundant, but since there is no primary key that's the only sure way to identify the old row.
MSalters
A: 

In this case you will need to use LinqToDataSets, if you do not wish to iterate through all rows. You can find Examples for LinqToDataSet here and here.

LinkText 1: http://msdn.microsoft.com/en-us/vbasic/bb688086.aspx

LinkText 2: http://msdn.microsoft.com/en-us/library/bb386977.aspx

this. __curious_geek
A: 

ok let me put this way....

I want to find a row in the dataset which has the exact contents of oldrow without using iteration...

So that now even w/o primary key i can ensure tht the contents of all the cells(columns) for each row would definitely be different..

so now i wanna find the row using all the cell(column) contents

Can u help me in this ?

stack_pointer is EXTINCT
Please update the question, instead of adding an answer.
MSalters