Можете ли вы увидеть, что не так с моим кодом и системой в Visual Studio Pro?
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;
namespace superpos3
{
public partial class itemss : Form
{
public itemss()
{
InitializeComponent();
}
MySqlConnection con = new MySqlConnection("server= localhost; database =superpos username= root; password=; ");
private object txtname;
private void itemss_Load(object sender, EventArgs e)
{
}
private void tabPage1_Click(object sender, EventArgs e)
{
}
private void tabPage1_Click_1(object sender, EventArgs e)
{
}
private void pictureBox2_Click(object sender, EventArgs e)
{
}
private void pictureBox1_Click(object sender, EventArgs e)
{
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = con;
cmd.CommandText = "insert into category(name,Description)values(@name,@Description)";
cmd.Parameters.AddWithValue("@name", txtna.Text);
cmd.Parameters.AddWithValue("@Description", txtdes.Text);
con.Open();
cmd.ExecuteNonQuery();
MessageBox.Show("Record added ..............");
con.Close();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
После этого я получил такую ошибку.
MySql.Data.MySqlClient.MySqlException
HResult=0x80004005
Message=Authentication to host 'localhost' for user '' using method 'mysql_native_password' failed with message: Access denied for user ''@'localhost' (using password: NO)
Inner Exception 1:
MySqlException: Access denied for user ''@'localhost' (using password: NO)
и детали вроде :
Sql.Data.MySqlClient.MySqlException
HResult=0x80004005
Message=Authentication to host 'localhost' for user '' using method 'mysql_native_password' failed with message: Access denied for user ''@'localhost' (using password: NO)
Source=MySql.Data
StackTrace:
at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.AuthenticationFailed(Exception ex)
at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.ReadPacket()
at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.Authenticate(Boolean reset)
at MySql.Data.MySqlClient.NativeDriver.Authenticate(String authMethod, Boolean reset)
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at superpos3.itemss.pictureBox1_Click(Object sender, EventArgs e) in D:\superpos3\superpos3\superpos3\itemss.cs:line 50
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at superpos3.Program.Main() in D:\superpos3\superpos3\superpos3\Program.cs:line 19
This exception was originally thrown at this call stack:
[External Code]
Inner Exception 1:
MySqlException: Access denied for user ''@'localhost' (using password: NO)
Проблема в том, что я даже не знаю, что случилось с моим кодом. Пожалуйста, объясните мне немного и дайте какое-то решение. Когда я нажимаю на просмотр деталей, там много информации. Полагаю, этого недостаточно.