Пытаюсь заполнить базы данных MYsql через Textbox
При нажатии на кнопку для заполнения бд происходит ошибка Fatal error encoutered during command execution
Код программы
using MySql.Data.MySqlClient;
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 SD = System.Data;
namespace DBredaction
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
public MySqlConnection mycon;
public MySqlCommand mycom;
public string connect = "Server=localhost;Database=catalog;Uid=root;pwd=;charset=utf8;";
public SD.DataSet ds;
private void button1_Click(object sender, EventArgs e)
{
try
{
string sql = "INSERT INTO employee (id, imia , familia , otchestvo, telephon)" +
"VALUES (@id, @imia, @familia, @otchestvo, @telephon);";
mycon = new MySqlConnection(connect);
mycon.Open();
MySqlCommand cmd = new MySqlCommand(sql, mycon);
//создаем параметры и добавляем их в коллекцию
cmd.Parameters.AddWithValue("@id", 5);
cmd.Parameters.AddWithValue("@imia", textBox1.Text);
cmd.Parameters.AddWithValue("@familia", textBox2.Text);
cmd.Parameters.AddWithValue("@otchestvo", textBox3.Text);
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button4_Click(object sender, EventArgs e)
{
try
{
mycon = new MySqlConnection(connect);
mycon.Open();
MessageBox.Show("DB CONNECT");
mycon.Close();
}
catch
{
MessageBox.Show("Connection lost");
}
}
}
}