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; using System.Configuration; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); conn.Open(); string checkuser = "select count (*) from UsersData where UserName= '" + UserName.Text + "'"; SqlCommand com = new SqlCommand(checkuser, conn); int temp = Convert.ToInt32(com.ExecuteScalar().ToString()); if (temp == 1) { Response.Write("User Already Exists"); } conn.Close(); } } protected void Submit_Click(object sender, EventArgs e) { try { Guid newGUDI = Guid.NewGuid(); SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["UsersConnectionString"].ConnectionString); conn.Open(); //line 35? string insertQuery = "insert into UsersData (ID, UserName, Password, CellPhone, DPT) values (@ID ,@Uname ,@Pass ,@Cell ,@DPT)"; SqlCommand com = new SqlCommand(insertQuery, conn); com.Parameters.AddWithValue("@ID", newGUDI.ToString()); com.Parameters.AddWithValue("@Uname", UserName.Text); com.Parameters.AddWithValue("@Pass", Password.Text); com.Parameters.AddWithValue("@DPT", DPT.SelectedItem.Text); com.ExecuteNonQuery(); Response.Redirect("UsersManger.aspx"); Response.Write("Registration SUCESSFULL"); conn.Close(); } catch (Exception ex) { Response.Write("Error:" + ex.ToString()); } } protected void DPT_SelectedIndexChanged(object sender, EventArgs e) { } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)