© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
5 replies
hercules_x_x

❔ 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
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ changing server from MYSQL to SQL server (Microsoft) in visual studio
C#CC# / help
2y ago
Visual Studio vs Visual Studio Code?
C#CC# / help
3y ago
#visual studio
C#CC# / help
2y ago
✅ Visual studio
C#CC# / help
3y ago