Connecting Tech Pros Worldwide Forums | Help | Site Map

Updating table with no key field

Zest4Csharp
Guest
 
Posts: n/a
#1: Nov 17 '05
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.

John B
Guest
 
Posts: n/a
#2: Nov 17 '05

re: Updating table with no key field


Zest4Csharp wrote:[color=blue]
> 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.[/color]
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
Guest
 
Posts: n/a
#3: Nov 17 '05

re: Updating table with no key field


Thnaks John,
create PK on the source table you mean? Or the table now in the DataSet?
--

"John B" wrote:
[color=blue]
> Zest4Csharp wrote:[color=green]
> > 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.[/color]
> 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
>[/color]
John B
Guest
 
Posts: n/a
#4: Nov 17 '05

re: Updating table with no key field


Zest4Csharp wrote:[color=blue]
> Thnaks John,
> create PK on the source table you mean? Or the table now in the DataSet?[/color]
On the source table.
If its MSSQL Server then you could use an IDENTITY column.

JB
Zest4Csharp
Guest
 
Posts: n/a
#5: Nov 17 '05

re: Updating table with no key field


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

=======
"John B" wrote:

[color=blue]
> Zest4Csharp wrote:[color=green]
> > Thnaks John,
> > create PK on the source table you mean? Or the table now in the DataSet?[/color]
> On the source table.
> If its MSSQL Server then you could use an IDENTITY column.
>
> JB
>[/color]
John B
Guest
 
Posts: n/a
#6: Nov 17 '05

re: Updating table with no key field


Zest4Csharp wrote:[color=blue]
> john,
> I cannot add a column as this will break other applications.[/color]
Why will it break other apps?[color=blue]
> 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?[/color]
Not to the best of my knowledge.
One of the SQL Server groups might be able to give you more information.

JB
[color=blue]
> Cheers
>
> =======
> "John B" wrote:
>
>
>[color=green]
>>Zest4Csharp wrote:
>>[color=darkred]
>>>Thnaks John,
>>>create PK on the source table you mean? Or the table now in the DataSet?[/color]
>>
>>On the source table.
>>If its MSSQL Server then you could use an IDENTITY column.
>>
>>JB
>>[/color][/color]
Chad Z. Hower aka Kudzu
Guest
 
Posts: n/a
#7: Nov 17 '05

re: Updating table with no key field


"=?Utf-8?B?WmVzdDRDc2hhcnA=?=" <Zest4Csharp@discussions.microsoft.com>
wrote in news:412EEC7D-6566-43E6-B271-435229194D0A@microsoft.com:[color=blue]
> 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.[/color]

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/
Chad Z. Hower aka Kudzu
Guest
 
Posts: n/a
#8: Nov 17 '05

re: Updating table with no key field


"=?Utf-8?B?WmVzdDRDc2hhcnA=?=" <Zest4Csharp@discussions.microsoft.com>
wrote in news:0044197A-C51A-49BE-864D-140610DF6850@microsoft.com:[color=blue]
> I cannot add a column as this will break other applications. However,[/color]

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?
[color=blue]
> i have realised that i can use the 'hidden' column ROWID in Oracle[/color]

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

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/
John B
Guest
 
Posts: n/a
#9: Nov 17 '05

re: Updating table with no key field


Zest4Csharp wrote:[color=blue]
> 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.[/color]
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
Closed Thread