using System; using System.Data; using System.Data.Sql; using System.Data.SqlClient; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class _Default : System.Web.UI.Page { //public string connectionString = "Data Source=local;Initial Catalog=webproms;Integrated Security=True"; public string connectionString="Data Source=THIS-9110C42D72\\SQLEXPRESS;Initial Catalog=webproms;Integrated Security=True"; protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == true) { } else { } } protected void btnSubmit_Click(object sender, EventArgs e) { LabelAccountCreated.Visible = false; bool usermatch = false; SqlConnection conn = new SqlConnection(connectionString); conn.Open(); String sqlstring = "SELECT accountUsername FROM accounts WHERE (accountUsername = '" + txtUsername.Text + "')"; SqlCommand checkUsername = new SqlCommand(sqlstring, conn); SqlDataReader usernames = checkUsername.ExecuteReader(); while (usernames.Read()) { if (usernames["accountUsername"].ToString() == txtUsername.Text) { usermatch = true; break; } } if (usermatch) { LabelUsernameError.Visible = true; if (accountCreated.Value == "-1") { rfvUsername.Visible = true; rfvUsername.Text = "Username already taken"; } else { accountCreated.Value = "0"; } PanelAccountCreation.Visible = true; PanelLogin.Visible = false; } else { webpromsDataSource.Insert(); PanelAccountCreation.Visible = false; PanelLogin.Visible = true; } usernames.Close(); conn.Close(); } }