protected void btnSave_click(object sender, EventArgs e) { try { con.Close(); con.Open(); maikal mk = new maikal(); strsn = mk.psid(); SqlCommand cmd = new SqlCommand("insert into PaperSetter(Code,Name,Designation,PAddress,PCity,PState,PPin,CAddress,CCity,CState,CPin,Phone,Fax,Mobile,DOB,Email,Age,Education,Experience) values(@Code,@Name,@Designation,@PAddress,@PCity,@PState,@PPin,@CAddress,@CCity,@CState,@CPin,@Phone,@Fax,@Mobile,@DOB,@Email,@Age,@Education,@Experience)", con); cmd.Parameters.AddWithValue("@Code", strsn.ToString()); cmd.Parameters.AddWithValue("@Name", txtName.Text.ToString()); cmd.Parameters.AddWithValue("@Designation", txtDEsignation.Text.ToString()); cmd.Parameters.AddWithValue("@PAddress", txtPAddress.Text.ToString()); cmd.Parameters.AddWithValue("@PState", ddlPState.SelectedItem.ToString()); cmd.Parameters.AddWithValue("@PCity", ddlPCity.SelectedItem.ToString()); cmd.Parameters.AddWithValue("@PPin", txtPPincode.Text.ToString()); cmd.Parameters.AddWithValue("@CAddress", txtCAddress.Text.ToString()); cmd.Parameters.AddWithValue("@CState", ddlCState.SelectedItem.ToString()); cmd.Parameters.AddWithValue("@CCity", ddlCCity.SelectedItem.ToString()); cmd.Parameters.AddWithValue("@CPin", txtCPin.Text.ToString()); cmd.Parameters.AddWithValue("@Phone", txtPhonecode.Text.ToString() + "-" + txtPhoneNo.Text.ToString()); cmd.Parameters.AddWithValue("@Fax", txtFaxCode.Text.ToString() + "-" + txtFaxNo.Text.ToString()); cmd.Parameters.AddWithValue("Mobile", txtMobile.Text.ToString()); cmd.Parameters.AddWithValue("@DOB", txtDOB.Text.ToString()); cmd.Parameters.AddWithValue("@Email", txtEmail.Text.ToString()); cmd.Parameters.AddWithValue("@Age", txtAge.Text.ToString()); cmd.Parameters.AddWithValue("@Education", txtEducationQ.Text.ToString()); cmd.Parameters.AddWithValue("@Experience", txtExperience.Text.ToString()); cmd.ExecuteNonQuery(); lblExcepiton.Text = "ID No.: " + strsn.ToString(); } catch (SqlException ex) { } finally { con.Close(); con.Dispose(); } }