ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.ASP.Net Error: ExecuteNonQuery: Connection property has not been initialized<p>Replace with below code.</p> <pre class="brush: csharp">int i = 0; try { // Extract Image File Name. string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName); //Set the Image File Path. string filePath = &#34;~/Images/&#34; + fileName; //Save the Image File in Folder. FileUpload1.PostedFile.SaveAs(Server.MapPath(filePath)); string constr = ConfigurationManager.ConnectionStrings[&#34;Q_SS_regnConnectionString1&#34;].ConnectionString; using (SqlConnection conn = new SqlConnection(constr)) { //string sql = &#34;INSERT INTO Q_SP_Afterlogin (Bussiness_name,city,email,name,toll_free,website_link,payment_mode,Image) VALUES (@Bname,@DropDownList2,@mail,@name,@toll,@link,@CheckBoxList1,@Image)&#34;; using (SqlCommand cmd = new SqlCommand(&#34;INSERT INTO Q_SP_Afterlogin (Bussiness_name,city,email,name,toll_free,website_link,payment_mode,Image) VALUES (@Bname,@DropDownList2,@mail,@name,@toll,@link,@CheckBoxList1,@Image)&#34;, conn)) { cmd.Parameters.AddWithValue(&#34;@Bname&#34;, DropDownList1.SelectedValue.ToString()); cmd.Parameters.AddWithValue(&#34;@DropDownList2&#34;, DropDownList2.SelectedValue.ToString()); cmd.Parameters.AddWithValue(&#34;@mail&#34;, mail.Text.Trim().ToString()); cmd.Parameters.AddWithValue(&#34;@toll&#34;, toll.Text.Trim().ToString()); cmd.Parameters.AddWithValue(&#34;@link&#34;, link.Text.Trim().ToString()); cmd.Parameters.AddWithValue(&#34;@name&#34;, name.Text.Trim().ToString()); cmd.Parameters.AddWithValue(&#34;@CheckBoxList1&#34;, CheckBoxList1.SelectedValue.ToString()); cmd.Parameters.AddWithValue(&#34;@Image&#34;, filePath); conn.Open(); i = cmd.ExecuteNonQuery(); conn.Close(); } } if (i &gt; 0) { lab.Text = &#34;Business information is added successfully.&#34;; lab.Visible = true; } else { lab.Text = &#34;Error while adding..!!&#34;; } } catch (Exception ex) { Response.Write(ex); }</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/110802/ASPNet-Error-ExecuteNonQuery-Connection-property-has-not-been-initialized/https://www.aspforums.net:443/Threads/110802/ASPNet-Error-ExecuteNonQuery-Connection-property-has-not-been-initialized/Tue, 23 Jul 2019 03:08:40 GMT