title: SqlConnection Runtime error
body: <p>Here i have write the coding for image upload control.but getting some RUNTIME error.error sows in SqlConnection place
  first i have<br>
  1.Image name box - Textbox <br>
  2.Image Upload control - asp imageupload control<br>
  3.Upload button<br></p>
  
  <p>ERROR :Object synchronization method was called from an unsynchronized block of code.</p>
  
  <p>Code Below</p>
  
  <pre><code>public partial class ProfileDetails : System.Web.UI.Page
   {
    string connStr =  ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
  //SqlConnection con = new SqlConnection("Data Source=CHATHU-LAPTOP;Initial Catalog=ProfilemgtDB;User ID=sa;Password=sa123");
  protected void Page_Load(object sender, EventArgs e)
  {
  
  }
  protected void Button1_Click(object sender, EventArgs e)
  {
  
  }
  
  protected void Upload_Click(object sender, EventArgs e)
  {
      string path = Server.MapPath("images/");
      if (FileUpload1.HasFile)
      {
          string ext = Path.GetExtension(FileUpload1.FileName);
          if (ext == ".jpg" || ext == ".png")
          {
              FileUpload1.SaveAs(path + FileUpload1.FileName);
              string name = "~/images/" + FileUpload1.FileName;
              string s = "Insert into Profile values('" + TextBox12.Text.Trim() + " '.'" + name + "' )";
  
              SqlConnection con = new SqlConnection(connStr);
              SqlCommand cmd = new SqlCommand(s, con);
              con.Open();
              cmd.ExecuteNonQuery();
              con.Close();
              Response.Write("File Uploaded");
          }
          else
          {
              Response.Write("You can upload only JPG &amp; PNG");
          }
  
      }
      else {
  
          Response.Write("Please Select File");
      }
      }
  }
  </code></pre>
  
  <p>ERROR :Object synchronization method was called from an unsynchronized block of code.</p>