Files
timelog/backendCS/routes/Reset.cs
T
2024-12-09 18:43:03 +02:00

31 lines
775 B
C#

using System.Net;
using MySql.Data.MySqlClient;
namespace TimelogBackend;
public class Reset : Route
{
public static void HandleRequest(HttpListenerResponse response)
{
try
{
// prepare SQL query
MySqlCommand cmd = new() { CommandText = "CALL InitDB" };
using (MySqlConnection conn = new MySqlConnection(connectionString))
{
cmd.Connection = conn;
// open connection
conn.Open();
// execute query
cmd.ExecuteNonQuery();
// set up and send response
SendSuccess(response);
}
}
catch (Exception ex)
{
SendError(response, ex);
}
}
}