using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using MySql.Data.MySqlClient; namespace Licenza { public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void Form2_Load(object sender, EventArgs e) { textBox2.MaxLength = 4; textBox3.MaxLength = 4; textBox4.MaxLength = 4; textBox5.MaxLength = 4; } private void button1_Click(object sender, EventArgs e) { string connectionString = "datasource=localhost;username=root;password=master;database=AlphaStudio"; MySqlConnection mySqlConnection = new MySqlConnection(connectionString); string selectString = "INSERT INTO `AlphaStudio`.`licenza` (`username`, `licenza`) VALUES ('" + textBox1.Text + "', '" + textBox2.Text +"-"+textBox3.Text +"-"+textBox4.Text + "-" + textBox5.Text + "');"; MySqlCommand mySqlCommand = new MySqlCommand(selectString, mySqlConnection); mySqlConnection.Open(); String strResult = String.Empty; strResult = (String)mySqlCommand.ExecuteScalar(); mySqlConnection.Close(); label1.Text = "You Are Register"; } } }