473,750 Members | 2,416 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

delete multiple rows from table doesnt contain primary key

In my project,i added datagridview to my form , i transfered my table to
datagridview and added multiple rows and when i called dataadapther.up date
,,result is ok. But when i tried it for the delete operations,i got the
error like "set primary key in your table" ,,i want delete multiple rows from
Datatable which doesnt contain primary key
Jun 27 '08 #1
3 3102
If your table doesn't have a primary key, then you'll need to supply a WHERE
clause that is distinct enough to disambiguate which rows to delete.
Peter

"Kayıhan" <Ka****@discuss ions.microsoft. comwrote in message
news:A0******** *************** ***********@mic rosoft.com...
In my project,i added datagridview to my form , i transfered my table to
datagridview and added multiple rows and when i called
dataadapther.up date
,,result is ok. But when i tried it for the delete operations,i got the
error like "set primary key in your table" ,,i want delete multiple rows
from
Datatable which doesnt contain primary key
Jun 27 '08 #2
instead of supply where clause, i prefer choose row from table and delete it
with
"row.Delete (); dataAdapther.Up date(table);" . idont understand why i am not
allowed; what is the harm about it? why primary key is needed for delete but
not for insert or update operations?
thanks

"Peter Bromberg [C# MVP]" wrote:
If your table doesn't have a primary key, then you'll need to supply a WHERE
clause that is distinct enough to disambiguate which rows to delete.
Peter

"Kayıhan" <Ka****@discuss ions.microsoft. comwrote in message
news:A0******** *************** ***********@mic rosoft.com...
In my project,i added datagridview to my form , i transfered my table to
datagridview and added multiple rows and when i called
dataadapther.up date
,,result is ok. But when i tried it for the delete operations,i got the
error like "set primary key in your table" ,,i want delete multiple rows
from
Datatable which doesnt contain primary key
Jun 27 '08 #3
Kayıhan wrote:
instead of supply where clause, i prefer choose row from table and delete it
with
"row.Delete (); dataAdapther.Up date(table);" . idont understand why i am not
allowed; what is the harm about it? why primary key is needed for delete but
not for insert or update operations?
thanks

"Peter Bromberg [C# MVP]" wrote:
>If your table doesn't have a primary key, then you'll need to supply a WHERE
clause that is distinct enough to disambiguate which rows to delete.
Peter

"Kayıhan" <Ka****@discuss ions.microsoft. comwrote in message
news:A0******* *************** ************@mi crosoft.com...
>>In my project,i added datagridview to my form , i transfered my table to
datagridvie w and added multiple rows and when i called
dataadapther. update
,,result is ok. But when i tried it for the delete operations,i got the
error like "set primary key in your table" ,,i want delete multiple rows
from
Datatable which doesnt contain primary key
What if you have multiple rows with the same data? I know you can simply
say "I know I don't", but .NET can't *know* that, and it requires
something to uniquely identify the rows to delete.

On a different note, every table should have a primary key or you'll
most likely have problems with it later on, like duplicate data.

--
Lasse Vågsæther Karlsen
mailto:la***@vk arlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3
Jun 27 '08 #4

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

Similar topics

1
8905
by: Andrew DeFaria | last post by:
I created the following .sql file to demonstrate a problem I'm having. According to the manual: If |ON DELETE CASCADE| is specified, and a row in the parent table is deleted, then InnoDB automatically deletes also all those rows in the child table whose foreign key values are equal to the referenced key value in the parent row. However:
2
2413
by: skidvd | last post by:
Hello: I have just recently converted to using the InnoDB table type so that I can enforce FOREIGN key constraints. I have been using MyISAM tables (accessed via JDBC) successfully for some time. However, I have just come across a problem with the new configuration that boggles my mind.... First some configuration data:
2
11797
by: Bob Ganger | last post by:
Hello, I am working on a project using SQL Server 2000 with a database containing about 10 related tables with a lot of columns containing text. The total current size of the database is about 2 Gig. When I delete data from the database, it takes a lot of system resources and monopolizes the database so that all other query requests are slow as mud! Ideally, I would like to be able to issue delete commands to the database on a...
11
9501
by: suma | last post by:
Hello, I want to delete duplicate rows in a table when no primary key is defined. For eg: If we have table1 with data as below, Suma 23 100 Suma 23 100 I want to delete a row from this table and retain only one row.
9
2796
by: Dejan | last post by:
Hy, Sorry for my terreble english I have this simple code for deleting rows in mysql table... Everything works fine with it. So, what do i wanna do...: my sql table looks something like this: id Name Surname pictr0 picrt1 pictr2 pictr3
6
3858
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called "Generations"), and it allows the user to add, edit and delete the various records of the table. "Generations" table has the following fields: "IDPerson", NamePerson", "AgePerson" and "IDParent". A record contains the information about a person (his name, his...
13
1886
by: =?Utf-8?B?VmVybm9uIFBlcHBlcnM=?= | last post by:
I am using VS2005. I created a Windows Appication project. Inside the Server Explorer, I created a new SQLExpress database, and then created a new table. I added the rows, making my first row an integer, and setting the identity property to true. I set that row to be my primary key. I then added a dataset, and added my table to the dataset. When I configure the table, I have no Update or Delete commands, even though the wizard has the...
7
15658
by: =?Utf-8?B?TG9zdEluTUQ=?= | last post by:
Hi All :) I'm converting VB6 using True DBGrid Pro 8.0 to VB2005 using DataGridView. True DBGrid has a MultipleLines property that controls whether individual records span multiple lines. Is there an equivalent property for the DataGridView? I have searched, but have not found one. I would like the user to be able to see all the columns of the table on one screen - thus eliminating the need to use the horizontal scroll bar to view...
5
2001
by: Tony Johansson | last post by:
Hello! Here I have a working program that delete the specified row in the database. It works fine but I want to fully understand it. In this example the SQLCommandBuilder will automatically create Sqlcommands for update, insert and delete. In this program I specify that I want to delete the row with primary key = "ZACHI"
0
9001
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
9584
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...
1
9344
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9257
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
8264
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
4893
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3327
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
2
2807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2226
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.