protected void Button1_Click(object sender, EventArgs e) { //SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); //con1.Open(); // checking existing useremail //SqlCommand cmd = new SqlCommand(" select user_email from userTable ", con1); //SqlDataReader dr = cmd.ExecuteReader(); // conneting to database with "ConnectionString" SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); con.Open(); SqlCommand cmd = new SqlCommand("insert into userTable values ('" + FNTextBox.Text + "', '" + LNTextBox.Text + "','" + TextBoxADRS.Text + "', '" + REGemailTextBox.Text + "', '" + REGpasswordTextBox.Text + "')", con); cmd.ExecuteNonQuery(); Signuplabel.Visible = true; Signuplabel.Text = "User registered successfully"; // set the textboxes to blank for next user to register FNTextBox.Text = ""; LNTextBox.Text = ""; TextBoxADRS.Text = ""; REGemailTextBox.Text = ""; REGcEmailTextBox.Text = ""; REGpasswordTextBox.Text = ""; REGcpasswordTextBox.Text = ""; FNTextBox.Focus(); }
private void AddAccount() { string name = FNTextBox.Text + " " + SNTextBox.Text; string x = GenerateUN(FNTextBox.Text.ToLower(), DEPcb.Text.ToUpper()); var success = "You have successfully created an account!\n\nYour username is : " + x + "\nYour password is : default\n\nThis can be changed when you log in for the first time."; _connection = DB_Connect.connect(); _connection.Open(); var sqlQuery = @"INSERT INTO[Users] ([Name], [Department], [UserName], [Password], [AccessLevel]) VALUES ('" + name + "', '" + DEPcb.Text + "', '" + x + "', '" + "default" + "', '" + ALcb.Text + "')"; _command = new SqlCommand(sqlQuery, _connection); _command.ExecuteNonQuery(); FNTextBox.Clear(); SNTextBox.Clear(); DEPcb.SelectedIndex = -1; ALcb.SelectedIndex = -1; FNTextBox.Focus(); MessageBox.Show(success); _connection.Close(); }