Updating table with no key field

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi,
I have a database table without a key field. I managed to view the contents
of the table through a DataSet in a DataGrid in C#. The user can edit the
data in the grid.
Can someone show me how to update the sourse database? I cannot use a
standard 'WHERE' claus simply because there is no key field in the source
table.
 
Zest4Csharp said:
hi,
I have a database table without a key field. I managed to view the contents
of the table through a DataSet in a DataGrid in C#. The user can edit the
data in the grid.
Can someone show me how to update the sourse database? I cannot use a
standard 'WHERE' claus simply because there is no key field in the source
table.
You must then define what it is you are going to treat as UNIQUE to
treat as a pseudo key.
Or you could create a PK on the table.

JB
 
Zest4Csharp said:
Thnaks John,
create PK on the source table you mean? Or the table now in the DataSet?
On the source table.
If its MSSQL Server then you could use an IDENTITY column.

JB
 
john,
I cannot add a column as this will break other applications. However, i have
realised that i can use the 'hidden' column ROWID in Oracle from which i am
queryuing the data. Does SQL Server has such a unique row identifier that is
normally hidden from the user?
Cheers

=======
:
 
Zest4Csharp said:
john,
I cannot add a column as this will break other applications. Why will it break other apps?
However, i have
realised that i can use the 'hidden' column ROWID in Oracle from which i am
queryuing the data. Does SQL Server has such a unique row identifier that is
normally hidden from the user?
Not to the best of my knowledge.
One of the SQL Server groups might be able to give you more information.

JB
 
=?Utf-8?B?WmVzdDRDc2hhcnA=?= said:
Can someone show me how to update the sourse database? I cannot use a
standard 'WHERE' claus simply because there is no key field in the
source table.

You need to return the key field so you can use it to update, or other set of uniquely identifying
fields and use those.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
 
=?Utf-8?B?WmVzdDRDc2hhcnA=?= said:
I cannot add a column as this will break other applications. However,

Then you need to find some other unique identifier in the data you have. Why would adding a column
break your other apps? Are they blindly dispalying all columsn sent to them instead of a set
formatting?
i have realised that i can use the 'hidden' column ROWID in Oracle

Using ROWID is a very bad idea. Very very bad idea. RowID's can change even between SQL
statements.
from which i am queryuing the data. Does SQL Server has such a unique
row identifier that is normally hidden from the user?

I dont think so. Those that posted use identity, thats something totally different thatn RowID and not
what you are looking for.



--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Get your ASP.NET in gear with IntraWeb!
http://www.atozed.com/IntraWeb/
 
Zest4Csharp said:
hi,
I have a database table without a key field. I managed to view the contents
of the table through a DataSet in a DataGrid in C#. The user can edit the
data in the grid.
Can someone show me how to update the sourse database? I cannot use a
standard 'WHERE' claus simply because there is no key field in the source
table.
One other thing you might consider would be working out which
combinations of fields are "supposed" to be unique then defining either
a pk or a unique constraint on these fields.
If there are duplicates (as I have found in the past when faced with
this dilemna), you can temporarily add an identity int column wich SQL
server will automagically fill in for you and then remove the duplicates
(using your identity column) and then drop this column.

HTH
JB
 
Back
Top