Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Task - Using DELETE | CRUD Operations with MySQL
course content

Зміст курсу

Introduction to .NET with C#

Task - Using DELETETask - Using DELETE

The shop owner decided to stop selling vegetables, and they need your help removing all the vegetables from the database.

Your task is to delete all the rows from the store table where the category is Vegetables.

Link to the Task: GitHub
The syntax for the delete statement is DELETE FROM table_name WHERE condition.

using MySql.Data.MySqlClient;

public class CRUD_Task_5
{
    // Write the connection string here
    public static string connectionString = "host=___;port=___;user=___;password=___;database=___";

    public static void Main(string[] args)
    {
        // Write code below this line
        using (MySqlConnection connection = new MySqlConnection(connectionString))
        {
            connection.Open();

            string cmdText = "DELETE FROM store where category = 'Vegetables';";
            MySqlCommand cmd = new MySqlCommand(cmdText, connection);
            cmd.ExecuteNonQuery();
        }
        // Write code above this line
    }
}
  

Все було зрозуміло?

Секція 4. Розділ 13
course content

Зміст курсу

Introduction to .NET with C#

Task - Using DELETETask - Using DELETE

The shop owner decided to stop selling vegetables, and they need your help removing all the vegetables from the database.

Your task is to delete all the rows from the store table where the category is Vegetables.

Link to the Task: GitHub
The syntax for the delete statement is DELETE FROM table_name WHERE condition.

using MySql.Data.MySqlClient;

public class CRUD_Task_5
{
    // Write the connection string here
    public static string connectionString = "host=___;port=___;user=___;password=___;database=___";

    public static void Main(string[] args)
    {
        // Write code below this line
        using (MySqlConnection connection = new MySqlConnection(connectionString))
        {
            connection.Open();

            string cmdText = "DELETE FROM store where category = 'Vegetables';";
            MySqlCommand cmd = new MySqlCommand(cmdText, connection);
            cmd.ExecuteNonQuery();
        }
        // Write code above this line
    }
}
  

Все було зрозуміло?

Секція 4. Розділ 13
some-alt