Hello,
I get an encoding related error when I want to check if my database connection is working when I press the "Connection" button on my form.
The error is on "conn.Open();".
I have attached my static class which contains the function for connection and the code where I call my function "Connection()"
I hope I can get help from you if possible.
I get an encoding related error when I want to check if my database connection is working when I press the "Connection" button on my form.
The error is on "conn.Open();".
I have attached my static class which contains the function for connection and the code where I call my function "Connection()"
I hope I can get help from you if possible.
C#:
using System;
using System.Text;
using MySql.Data;
using MySql.Data.MySqlClient;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace GestionHotel
{
public static class Fonctions
{
private static String cs = @"server=localhost;userid=root;password=;database=gestionhotelentretien;charset=utf8";
private static MySqlConnection conn = new MySqlConnection(cs);
public static bool Connexion()
{
conn.Open();
if (conn.State == System.Data.ConnectionState.Open)
{
return true;
}
else
{
return false;
}
}
public static bool Deconnexion()
{
conn.Close();
return (conn.State == System.Data.ConnectionState.Closed);
}
}
}