473,657 Members | 2,397 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Updating table with no key field

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.
Nov 17 '05 #1
8 1376
Zest4Csharp wrote:
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
Nov 17 '05 #2
Thnaks John,
create PK on the source table you mean? Or the table now in the DataSet?
--

"John B" wrote:
Zest4Csharp wrote:
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

Nov 17 '05 #3
Zest4Csharp wrote:
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
Nov 17 '05 #4
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:

Zest4Csharp wrote:
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

Nov 17 '05 #5
Zest4Csharp wrote:
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
Cheers

=======
"John B" wrote:
Zest4Csharp wrote:
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

Nov 17 '05 #6
"=?Utf-8?B?WmVzdDRDc2h hcnA=?=" <Ze*********@di scussions.micro soft.com>
wrote in news:41******** *************** ***********@mic rosoft.com:
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/
"Programmin g is an art form that fights back"

Empower ASP.NET with IntraWeb
http://www.atozed.com/IntraWeb/
Nov 17 '05 #7
"=?Utf-8?B?WmVzdDRDc2h hcnA=?=" <Ze*********@di scussions.micro soft.com>
wrote in news:00******** *************** ***********@mic rosoft.com:
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/
"Programmin g is an art form that fights back"

Get your ASP.NET in gear with IntraWeb!
http://www.atozed.com/IntraWeb/
Nov 17 '05 #8
Zest4Csharp wrote:
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
Nov 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
16158
by: Jason | last post by:
Let's say I have an html form with 20 or 30 fields in it. The form submits the fields via POST to a php page which updates a table in a database with the $_POST vars. Which makes more sense? 1) simply UPDATING the values for all fields in the table, whether or not any particular field has actually changed 2) running a second SELECT statement and comparing the $_POST vars to the returned values, and only UPDATING those that have...
1
5947
by: Srinadh | last post by:
Hi all, We have files with about 20 to 30 fields per row. We are trying to update such files with about 60 rows as contiguous data in a CLOB field. It passes through. But when we try updating files with about 60 to 200 rows, we get the
6
2997
by: Hasanain F. Esmail | last post by:
Hi all, I sincerly thank you all in advance for your help to solve this problem. I have been trying to find a solution to this problem for sometime now but have failed. I am working on a project that requires updating data every month. A typical examle is an apartment rental software but could be applied
2
2391
by: Ray Holtz | last post by:
I have a form that shows a single record based on a query criteria. When I click a button it is set to use an append query to copy that record to a separate table, then deletes the record from the first table. Both tables have a 'DateTime' field that shows when it was last updated using the Now function. What I am trying to do is get the 'DateTime' field updated after the append query copies it to the new table. I have tried updating...
5
2026
by: junglist | last post by:
Hi guys, I've been trying to implement an editable datagrid and i have been succesful up to the point where i can update my datagrid row by row. However what used to happen was that once i updated one row, all of them were updated so i immediatelly figured out that i have to include the id of every entry in the update statement. This is where the problem is raised. My database is an Access database. The table i am updating contains a Date...
11
3058
by: Eych | last post by:
I get a VB error when I try to update a table whose field I change with the following statement: dcUpdate.Dataset.Tables(0).Rows(0)("User Name") = Me.textbox1.Text if I change the field name to "UserName", one word, in the table and in the statement above, it works... realistically, I can't do this since the users already have a copy of
4
2370
by: Geoff | last post by:
Hi I'm hoping somebody can help me with the following problem that has occurred to me. Suppose I have two tables in an SQL Server database. Let's call these tables A and B. Assume that A has two fields: a primary key and another holding a string. In table B there are three fields: a primary key, a foreign key (which links to the primary key in A) and other field holding a string.
33
3312
by: bill | last post by:
In an application I am writing the user can define a series of steps to be followed. I save them in a sql database using the field "order" (a smallint) as the primary key. (there are in the range of 20 steps) On the admin page the steps are listed, in "order" order and the user can create new steps and assign an order and all is well. The problem may come in using a renumber function which should take the steps in their current order...
2
3309
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
Hi All! I am with a situation where I am not getting the right updating to the form's fields. The situation is the following one: I have one combobox and one textbox. I am using the CurrentChanged event of the BindingSource of the combobox to update the textbox. When selecting an item in the combobox or when selecting a row in the grid, it is updating the textbox correctly. The problem is when I apply a filter in the grid, and then...
0
2490
by: Mike | last post by:
So here's the situation (.NET 2.0 btw): I have a form, and on this form is a textbox among many other databound controls. The textbox is bound to a field in a data table via the Text property. In this table there are multiple columns that cannot be NULL, which, are bound to other controls (but they're not really important at this time). I create a new row via the currency manager like so: _currencyManager.AddNew() _currentRow =...
0
8402
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8829
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8734
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8608
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7341
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5633
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4164
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.