I've found many suggestions to fix this unprocessed exception, and I have tried every one I could find (and understand). It's been hours, but still no results... I've created a windows forms application that asks for a client's information and I'm trying to Insert this info into a DB I have created in MySQL. This is the code that seems to be working for everyone but me:
public partial class Form1 : Form
{
private MySqlConnection mConn;
public Form1()
{
InitializeComponent();
mConn = new MySqlConnection("Persist Security Info=False; server=localhost; database=xxxxxxx;uid=yyyyyyy;password=zzzzzzzz");
}
private void button1_Click(object sender, EventArgs e)
{
mConn.Open();
if (mConn.State == ConnectionState.Open)
{
MySqlCommand command = new MySqlCommand("INSERT INTO client VALUES (" + textBox1.Text + ",' " + textBox2.Text + "', '" + textBox3.Text + "'," + textBox4.Text + ",' " + textBox5.Text + "')", mConn);
command.ExecuteNonQuery();
mConn.Close();
}
else
MessageBox.Show("Connection Failed!");
}
}
This is the exception text:
MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts. ---> System.Net.Sockets.SocketException (0x80004005): The requested adress is not valid in this context [::1]:3306 in ...
If you can help me I'll be very grateful. It's my first year programming and so far it has passed quite well, but now I have been "left behind" in my class because of this recurring error. Thank you in advance :)