**
> CREATE TABLE devices ( id int NOT NULL primary key
> auto_increment, Name varchar(255) NOT NULL statuses_chekid id
> int ); CREATE TABLE devices_atribut ( id int NOT NULL primary
> key auto_increment, devices_id int NULL, Name varchar(255) NOT
> NULL, Model 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, constraint s2
> foreign key(devices_id) references devices(id) ); -- ENGINE=InnoDB
> DEFAULT CHARSET=utf8; CREATE TABLE devices_type ( id int NOT NULL
> primary key auto_increment, Name varchar(255) NOT NULL, status_id
> int null, constraint s1 foreign key(status_id) references
> devices(id) ); -- ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE
> statuses ( id int NOT NULL primary key auto_increment,
> device_id int null, status_name varchar(255) NOT NULL,
> constraint s3 foreign key(device_id) references devices(id) ); --
> ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE statuses_chekid (
> id int NOT NULL primary key auto_increment, time date NOT NULL,
> status_id int null, devices_id int NULL, constraint s4 foreign
> key(status_id) references statuses(id), );
> ----------------------------------C#code----------------------------------- 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=d_base;");
> conn.Open();
> MySqlCommand num = new MySqlCommand("INSERT INTO `devices` ( `Name`) VALUES ( '" + box1 + "')", conn);
> num.ExecuteNonQuery();
> //MessageBox.Show("Your data has been transferred to the database");
> MySqlCommand dev = new MySqlCommand("INSERT INTO `devices_type` ( `Name`) VALUES ( '" + box2 + "')", conn);
> dev.ExecuteNonQuery();
> 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());
> }
> }
> } }
**