"Unknown column 'devices_id' in 'field list'", как решить эту проблему?

**

**

        using MySql.Data.MySqlClient;
        using NPOI.OpenXmlFormats.Dml.Spreadsheet;
        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;
        namespace My_tax_Project
        {
            public partial class Form1 : Form
            {
                public Form1()
                {
                    InitializeComponent();
                }
                private void Form1_Load(object sender, EventArgs e)
                {
                }
                private void label10_Click(object sender, EventArgs e)
                {
                }
                private void add_buttn_Click(object sender, EventArgs e)
                {
                    try
                    {
                    string box1 = device_name.Text;
                    string box2 = d_type_name.Text;
                    string box3 = status_box.Text;
                    string box4 = atribute_name.Text;
                    string box5 = username.Text;
                    string box6 = section_name.Text;
                    string box7 = os_name.Text;
                    string box8 = code.Text;
                    string box9 = login_box.Text;
                    string box10 = host.Text;
                    string box11 = cpu_box.Text;
                    string box12 = ip.Text;
                    string box13 = data_name.Text;
                    MySqlConnection conn = new MySqlConnection("server=localhost;port=3306;username=root;password=root;database=bazzaa;");
                    conn.Open();
                    MySqlCommand num = new MySqlCommand("INSERT INTO `devices` ( `Name`) VALUES ( '"+box1+"')", conn);
                   num.ExecuteNonQuery();
                        long device_id = num.LastInsertedId;
                        Console.WriteLine(device_id);

                        //MessageBox.Show("Your data has been transferred to the database");
                        MySqlCommand dev = new MySqlCommand("INSERT INTO `devices_type` ( `Name`,`devices_id`) VALUES ( '" + box2 + "',@id )", conn);
                        dev.Parameters.AddWithValue("@id", device_id);
                        dev.ExecuteNonQuery();
                        //*****************//exception//**************

                        MySqlCommand stat = new MySqlCommand("INSERT INTO `statuses` ( `status_name`) VALUES ('"+box3+ "' )", conn);
                    stat.ExecuteNonQuery();
                    MySqlCommand s_chekid = new MySqlCommand("INSERT INTO `statuses_chekid` ( `time`) VALUES ('"+box13+ "')", conn);
                    s_chekid.ExecuteNonQuery();
                    MySqlCommand atr = new MySqlCommand("INSERT INTO `devices_atribut` ( `Name`, `Code`, `Username`, `Section`, `ip_adrerss`, `OS`, `Login`, `Host_Name`, `CPU`) VALUES ('" + box4 + "','" + box8 + "','" + box5 + "','" + box6 + "','" + box12 + "','" + box7 + "','" + box9 + "','" + box10 + "','" + box11 + "')", conn);
                        atr.ExecuteNonQuery();



                        MessageBox.Show("Your data has been transferred to the database");
                    conn.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                        Console.WriteLine(ex);
                    }
                }
                private void cansel_Click(object sender, EventArgs e)
                {
                    this.Close();

                }
            }
        }

    *********************************************************************************************************
    -- phpMyAdmin SQL Dump
    -- version 4.9.5
    -- https://www.phpmyadmin.net/
    --
    -- Host: localhost:3306
    -- Generation Time: May 20, 2020 at 07:33 AM
    -- Server version: 5.7.24
    -- PHP Version: 7.4.1

    SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
    SET AUTOCOMMIT = 0;
    START TRANSACTION;
    SET time_zone = "+00:00";


    /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
    /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
    /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
    /*!40101 SET NAMES utf8mb4 */;

    --
    -- Database: `d_base`
    --

    -- --------------------------------------------------------

    --
    -- Table structure for table `devices`
    --

    CREATE TABLE `devices` (
      `id` int(11) NOT NULL,
      `Name` varchar(255) NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    -- --------------------------------------------------------

    --
    -- Table structure for table `devices_atribut`
    --

    CREATE TABLE `devices_atribut` (
      `id` int(11) NOT NULL,
      `devices_id` int(11) DEFAULT NULL,
      `Name` varchar(255) NOT NULL,
      `Code` varchar(255) NOT NULL,
      `Username` varchar(11) NOT NULL,
      `Section` varchar(255) NOT NULL,
      `ip_adrerss` varchar(255) NOT NULL,
      `OS` varchar(255) NOT NULL,
      `Login` varchar(255) NOT NULL,
      `Host_Name` varchar(255) NOT NULL,
      `CPU` varchar(255) NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    --
    -- Dumping data for table `devices_atribut`
    --

    INSERT INTO `devices_atribut` (`id`, `devices_id`, `Name`, `Code`, `Username`, `Section`, `ip_adrerss`, `OS`, `Login`, `Host_Name`, `CPU`) VALUES
    (9, NULL, 'dfgdfg', 'dfgdfgdf', 'dfgd', 'gdfg', '65656565', 'dfgdfg', 'dfgdfg', 'dgdfg', 'dfgdfgd');

    -- --------------------------------------------------------

    --
    -- Table structure for table `devices_type`
    --

    CREATE TABLE `devices_type` (
      `id` int(11) NOT NULL,
      `Name` varchar(255) NOT NULL,
      `devices_st_id` int(11) DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    --
    -- Dumping data for table `devices_type`
    --

    INSERT INTO `devices_type` (`id`, `Name`, `devices_st_id`) VALUES
    (37, 'dfgdgd', NULL),
    (38, 'fdf', 47),
    (39, 'fdf', 47);

    -- --------------------------------------------------------

    --
    -- Table structure for table `statuses`
    --

    CREATE TABLE `statuses` (
      `id` int(11) NOT NULL,
      `device_id` int(11) DEFAULT NULL,
      `status_name` varchar(255) DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    --
    -- Dumping data for table `statuses`
    --

    INSERT INTO `statuses` (`id`, `device_id`, `status_name`) VALUES
    (39, NULL, 'use');

    -- --------------------------------------------------------

    --
    -- Table structure for table `statuses_chekid`
    --

    CREATE TABLE `statuses_chekid` (
      `id` int(11) NOT NULL,
      `time` datetime(6) NOT NULL,
      `status_id` int(11) DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

    --
    -- Dumping data for table `statuses_chekid`
    --

    INSERT INTO `statuses_chekid` (`id`, `time`, `status_id`) VALUES
    (24, '2020-05-14 00:00:00.000000', NULL);

    --
    -- Indexes for dumped tables
    --

    --
    -- Indexes for table `devices`
    --
    ALTER TABLE `devices`
      ADD PRIMARY KEY (`id`);

    --
    -- Indexes for table `devices_atribut`
    --
    ALTER TABLE `devices_atribut`
      ADD PRIMARY KEY (`id`),
      ADD KEY `devices_id` (`devices_id`),
      ADD KEY `devices_id_2` (`devices_id`);

    --
    -- Indexes for table `devices_type`
    --
    ALTER TABLE `devices_type`
      ADD PRIMARY KEY (`id`),
      ADD KEY `devices_st_id` (`devices_st_id`);

    --
    -- Indexes for table `statuses`
    --
    ALTER TABLE `statuses`
      ADD PRIMARY KEY (`id`),
      ADD KEY `device_id` (`device_id`);

    --
    -- Indexes for table `statuses_chekid`
    --
    ALTER TABLE `statuses_chekid`
      ADD PRIMARY KEY (`id`),
      ADD KEY `status_id` (`status_id`);

    --
    -- AUTO_INCREMENT for dumped tables
    --

    --
    -- AUTO_INCREMENT for table `devices`
    --
    ALTER TABLE `devices`
      MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=48;

    --
    -- AUTO_INCREMENT for table `devices_atribut`
    --
    ALTER TABLE `devices_atribut`
      MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;

    --
    -- AUTO_INCREMENT for table `devices_type`
    --
    ALTER TABLE `devices_type`
      MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=40;

    --
    -- AUTO_INCREMENT for table `statuses`
    --
    ALTER TABLE `statuses`
      MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=40;

    --
    -- AUTO_INCREMENT for table `statuses_chekid`
    --
    ALTER TABLE `statuses_chekid`
      MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;

    --
    -- Constraints for dumped tables
    --

    --
    -- Constraints for table `devices_atribut`
    --
    ALTER TABLE `devices_atribut`
      ADD CONSTRAINT `s2` FOREIGN KEY (`devices_id`) REFERENCES `devices` (`id`);

    --
    -- Constraints for table `devices_type`
    --
    ALTER TABLE `devices_type`
      ADD CONSTRAINT `s1` FOREIGN KEY (`devices_st_id`) REFERENCES `devices` (`id`);

    --
    -- Constraints for table `statuses`
    --
    ALTER TABLE `statuses`
      ADD CONSTRAINT `s3` FOREIGN KEY (`device_id`) REFERENCES `devices` (`id`);

    --
    -- Constraints for table `statuses_chekid`
    --
    ALTER TABLE `statuses_chekid`
      ADD CONSTRAINT `s4` FOREIGN KEY (`status_id`) REFERENCES `statuses` (`id`);
    COMMIT;

    /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
    /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
    /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

**


Ответы (0 шт):