Problème accès base de données C# MySQL Workbench
maxmd
Messages postés
6
Date d'inscription
Statut
Membre
Dernière intervention
-
maxmd Messages postés 6 Date d'inscription Statut Membre Dernière intervention -
maxmd Messages postés 6 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
j'ai un problème quand j'essaye d'accéder a une base de données MySQL Workbench a partir de visual studio desktop(express 2015)
ca donne Une exception non gérée du type 'MySql.Data.MySqlClient.MySqlException' s'est produite dans MySql.Data.dll
Informations supplémentaires : Authentication to host 'localhost' for user 'root' using method 'mysql_native_password' failed with message: Unknown database 'dbb'
merci
j'ai un problème quand j'essaye d'accéder a une base de données MySQL Workbench a partir de visual studio desktop(express 2015)
ca donne Une exception non gérée du type 'MySql.Data.MySqlClient.MySqlException' s'est produite dans MySql.Data.dll
Informations supplémentaires : Authentication to host 'localhost' for user 'root' using method 'mysql_native_password' failed with message: Unknown database 'dbb'
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using MySql.Web;
namespace hd
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "")
{
MessageBox.Show("entrez Nom d’utilisateur et Mot de passe");
return;
}
string myConnection = "Server=localhost;port=3306;Database=dbb;username=root;password=psw";
MySqlConnection myConn = new MySqlConnection(myConnection);
MySqlCommand cmd = new MySqlCommand("Select * Role from Agent where UserName=@UserName and Password=@Password", myConn);
cmd.Parameters.AddWithValue("@UserName", textBox1.Text);
cmd.Parameters.AddWithValue("@Password", textBox2.Text);
myConn.Open();
MySqlDataAdapter adapt = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet();
adapt.Fill(ds);
int count = ds.Tables[0].Rows.Count;
if (count == 1)
{
if (ds.Tables[0].Rows[0]["Role"].ToString() == "admin")
{
frmadmin fm = new frmadmin();
fm.Show();
}
}
myConn.Close();
}
}
}
merci
A voir également:
- Problème accès base de données C# MySQL Workbench
- Fuite données maif - Guide
- Base de registre - Guide
- Acces rapide - Guide
- Supprimer les données de navigation - Guide
- Accès refusé - Guide