приложение winforms, пытаюсь добавить данные в базу Mysql. в combobox вывел список таблиц, выбираю один из таблиц и пытаюсь добавить данные в эту таблицу выходить такая ошибка authentication to host for user using method 'mysql_native_password' failed with message: Access denied for user "@'DESKTOP-8BR4U(using password: NO). в mysql давал все привилегий для пользователя. не знаю в чем может быть проблема. помогите разобраться. ниже выложил таблицу user host баз данных. и собственно код.
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 Biling_DSLAM
{
public partial class Openpage : Form
{
public Openpage()
{
InitializeComponent();
}
MySqlConnection con = new MySqlConnection();
int id;
string query;
private void Openpage_Load(object sender, EventArgs e)
{
MySqlConnection con = new MySqlConnection("Data Source = 192.168.1.102; UserId = admin; Password = 12345");
con.Open();
var command = new MySql.Data.MySqlClient.MySqlCommand();
command.Connection = con;
command.CommandType = CommandType.Text;
command.CommandText = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'dslam'";
var adapter = new MySql.Data.MySqlClient.MySqlDataAdapter(command);
var dataset = new DataSet();
adapter.Fill(dataset);
DataTable dt = dataset.Tables[0];
for (int i = 0; i < dataset.Tables[0].Rows.Count; i++)
{
comboBox1.Items.Add(dataset.Tables[0].Rows[i][0].ToString());
con.Close();
}
}
private DataTable AutoNumberedTable(DataTable SourceTable)
{
DataTable ResultTable = new DataTable();
DataColumn AutoNumberColumn = new DataColumn
{
ColumnName = "id",
DataType = typeof(int),
AutoIncrement = true,
AutoIncrementSeed = 1,
AutoIncrementStep = 1
};
ResultTable.Columns.Add(AutoNumberColumn);
ResultTable.Merge(SourceTable);
return ResultTable;
}
private void Addbutton_Click(object sender, EventArgs e)
{
try
{
if (comboBox1.Items.ToString() == "sats60")
{
query = "insert into sta60(id, name, surname, phone, login, dslam, port, date) Values (null, '" + Nametextbox.Text + "', '" + Surnametextbox.Text + "', '" + phonetextbox.Text + "', '" + logintextbox.Text + "', '" + dslamcomboBox.Text + "', '" + porttextbox.Text + "', '" + dateTimePicker1.Text + "')";
}
if (comboBox1.Items.ToString() == "sats70")
{
query = "insert into sta70(id, name, surname, phone, login, dslam, port, date) Values (null, '" + Nametextbox.Text + "', '" + Surnametextbox.Text + "', '" + phonetextbox.Text + "', '" + logintextbox.Text + "', '" + dslamcomboBox.Text + "', '" + porttextbox.Text + "', '" + dateTimePicker1.Text + "')";
}
MySqlCommand command = new MySqlCommand(query, con);
con.Open();
if (command.ExecuteNonQuery() == 1)
{
MessageBox.Show("Added!");
}
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error!");
con.Close();
}
}
private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
id = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString());
Nametextbox.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString();
Surnametextbox.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString();
phonetextbox.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString();
logintextbox.Text = dataGridView1.CurrentRow.Cells[4].Value.ToString();
dslamcomboBox.Text = dataGridView1.CurrentRow.Cells[5].Value.ToString();
porttextbox.Text = dataGridView1.CurrentRow.Cells[6].Value.ToString();
dateTimePicker1.Text = dataGridView1.CurrentRow.Cells[7].Value.ToString();
DataSetDateTime.Local.ToString();
}
private void Exitbutton_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}