473,239 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,239 software developers and data experts.

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.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
Jun 27 '08 #1
3 3072
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****@discussions.microsoft.comwrote in message
news:A0**********************************@microsof t.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.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
Jun 27 '08 #2
instead of supply where clause, i prefer choose row from table and delete it
with
"row.Delete(); dataAdapther.Update(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****@discussions.microsoft.comwrote in message
news:A0**********************************@microsof t.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.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
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.Update(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****@discussions.microsoft.comwrote in message
news:A0**********************************@microso ft.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.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***@vkarlsen.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
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...
2
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...
2
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...
11
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...
9
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...
6
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...
13
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...
7
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...
5
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...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.