Conteúdo do Curso
Introduction to .NET with C#
2. Asynchronous Programming and Introduction to Web Services
3. Introduction to Databases with .NET
Introduction to .NET with C#
Task - 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
.
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
}
}
Tudo estava claro?
Seção 4. Capítulo 13
Conteúdo do Curso
Introduction to .NET with C#
2. Asynchronous Programming and Introduction to Web Services
3. Introduction to Databases with .NET
Introduction to .NET with C#
Task - 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
.
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
}
}
Tudo estava claro?
Seção 4. Capítulo 13