User registration in WinForms through the database.
I can’t figure it out, I made registration in WinForms through the SQL server management studio database, I need to make it so that you cannot register the data that has already been registered and are in the database, help!
private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" || textBox6.Text == "") { MessageBox.Show("Пожалуйста, заполните все поля для регистрации!!!"); } else { SqlConnection con = new SqlConnection(@"Data Source=sql2016;Initial Catalog=Stolovka;Integrated Security=True;"); con.Open(); string str = "insert into Users(Login,Password,Name,Surname,Patronymic,Telefon) values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "')"; SqlCommand cmd = new SqlCommand(str, con); cmd.ExecuteNonQuery(); MessageBox.Show("Пользователь зарегистрирован!!!"); } }