0
MySql.Data.MySqlClient.MySqlException
類型的未處理的異常出現在MySql.Data.dll
C#:MySQL的例外是未處理
其他信息:每當我試圖運行我的程序
Access denied for user 'groupdes_ling'@'60.50.32.226' (using password: YES)
出現此錯誤。該編碼粘貼下面:
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 GroupDesignProject
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
string MyConnectionString = "Server=31.220.105.189;Database=groupdes_GDP;Uid=groupdes_ling;Pwd=0164851286;";
MySqlConnection connection = new MySqlConnection(MyConnectionString);//create connection
MySqlCommand cmd;
connection.Open();//connect to database
//write INSERT command and execute
cmd = connection.CreateCommand();//create command
cmd.CommandText = "INSERT INTO trial (Name)values ('" + textBox1.Text + "');";
cmd.ExecuteNonQuery();
//disconnect from database
if (connection.State == ConnectionState.Open)
{
connection.Close();
}
}
}
}
我仍然不能設法解決這個錯誤。感謝您的幫助