❔ inserting data from visual studio to mysql databases

namespace hw6q1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
string x = "server =localhost; database =registration; uid =root; password =123456";
MySqlConnection conn = new MySqlConnection(x);
string y = "INSERT INTO registration(Firstname,Lastname,Address,City,State,Postcode,country,Email) VALUES(" + textBox1.Text + ",'" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "')";

try
{
conn.Open();
MySqlCommand command = new MySqlCommand(y, conn);
int z = Convert.ToInt32(command.ExecuteNonQuery());
command.Dispose();
conn.Close();

}
catch (MySqlException ex)
{
MessageBox.Show(ex.Message);
}
}
}
}


cant show the result no matter how i try
Screenshot_8.png
Was this page helpful?