---
title: "Deleting multiple rows from a table"  
description: "Deleting multiple rows from a table"  
author: "Aaron Douglas"  
published: 2013-09-28  
updated: 2013-09-28  
canonical: https://www.mindstick.com/forum/1562/deleting-multiple-rows-from-a-table  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Deleting multiple rows from a table

I have a [table](https://www.mindstick.com/articles/43918/how-to-design-table-using-bootstrap) and I want to [delete](https://www.mindstick.com/forum/33620/how-to-delete-record-from-list-in-mvc-using-ajax) all rows with a specific card serial . There are [multiple rows](https://www.mindstick.com/forum/160908/how-to-concatenate-text-from-multiple-rows-into-a-single-text-string-in-sql-server) with the same card serial .So I wrote this [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) but it seems that's not working:

```
try
{
using (SqlConnection con = new SqlConnection(WF_AbsPres.Properties.Settings.Default.DbConnectionString))
{
   con.Open();
   SqlCommand command2 = new SqlCommand("DELETE  FORM DevInOut where Cardserial='" + textBox5.Text + "'", con);
   command2.ExecuteNonQuery();
   con.Close();
}
}
   catch (SqlException ex)
{
}
```

how can assure all the rows will be [deleted](https://www.mindstick.com/forum/160487/how-to-remove-the-deleted-git-code-marker-in-scrollbar-in-visual-studio-2022) . Should I use [procedure](https://www.mindstick.com/forum/32/stored-procedure-return-datatype)? How do I use procedure?\

## Replies

### Reply by Madam Walker

Hey Aaron!

Change your FORM to FROM.

\

```
using (SqlConnection con = new SqlConnection(WF_AbsPres.Properties.Settings.Default.DbConnectionString))
{
   con.Open();
   SqlCommand command2 = new SqlCommand("DELETE FROM DevInOut where Cardserial=@Cardserial", con);
   commdand2.Parameters.AddWithValue("@Cardserial", textBox5.Text);
   command2.ExecuteNonQuery();
   con.Close();
}
```


---

Original Source: https://www.mindstick.com/forum/1562/deleting-multiple-rows-from-a-table

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
