using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; namespace WebApplication1 { public partial class _Default : System.Web.UI.Page { protected void Button1_Click(object sender, EventArgs e) { gumb(); Label2.Text = (TextBox1.Text+" "+"Thank you for participating"); } protected void gumb() { SqlConnection myConnection = new SqlConnection("user id= ; password= ; server= ; database=; "); do { try { myConnection.Open(); } catch (Exception e) { Console.WriteLine(e.ToString()); } } while (myConnection.State != System.Data.ConnectionState.Open); SqlCommand myCommand = new SqlCommand("INSERT INTO emails (ime, priimek, email) " + "Values ('"+TextBox1.Text+"','"+TextBox2.Text+"','"+TextBox3.Text+"')", myConnection); myCommand.ExecuteNonQuery(); try { myConnection.Close(); } catch (Exception e) { Console.WriteLine(e.ToString()); } } } }
i made this program so that it stores emails of the users that want to participate in a contest but i cant connect to my MySql host
i get this error in the open catch exeption loop: A first chance exception of type 'System.ArgumentOutOfRangeException' occurred in System.Data.dll