using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace WadhwaGroup { public partial class WadhwaGroup : System.Web.UI.Page { string ConnectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"]; string myStringVariable; static string name = ""; static string mobileno = ""; static string emailid = ""; protected void Page_Load(object sender, EventArgs e) { name = Request.Form["name"].ToString(); mobileno = Request.Form["mobile"].ToString(); emailid = Request.Form["email"].ToString(); using (SqlConnection cn = new SqlConnection(ConnectionString)) { try { cn.Open(); SqlCommand command = new SqlCommand(); command.Parameters.Add(new SqlParameter("@name", SqlDbType.VarChar)).Value = name.Trim(); command.Parameters.Add(new SqlParameter("@mobileno", SqlDbType.VarChar)).Value = mobileno.Trim(); command.Parameters.Add(new SqlParameter("@email", SqlDbType.VarChar)).Value = emailid.Trim(); command.CommandText = "Insert Into Wadhwa_Leads(name,mobileno,email) " + "Values(@name,@mobileno,@email)"; command.Connection = cn; command.ExecuteNonQuery(); cn.Close(); } catch (Exception ex) { Response.Write("Error in form submit" + ex.ToString()); return; } } Response.Write("Thank you for your details. One of our representative will get back to you shortly."); } } }