Hello, I made the authorization of the user in the program through the database by login and password. I wanted to after the login. The data of the authorized user was output. Please help me figure out how to implement this. Here is the authorization code:
using (var con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\User\Desktop\база\Питание.mdf;Integrated Security=True;Connect Timeout=30")) { con.Open(); using (var cmd = new SqlCommand("Select Count (1) From Регистрация where Логин=@login and Пароль=@Pass", con)) { cmd.Parameters.AddWithValue("login", textBox1.Text); cmd.Parameters.AddWithValue("Pass", textBox2.Text); var accountsCount = (int)cmd.ExecuteScalar(); if (accountsCount==1) { Form5 a = new Form5(); a.label1.Text = accountsCount.ToString(); a.Show(); } else { MessageBox.Show("Неверные данные"); } } }
textBox1.Textor some other information means? I also hope you understand that this “authorization” will not save you from a person who connects to the file directly (for example, through the management studio) and reads all logins and passwords. - default localeРегистрация. What is the problem to write the same query to the table, sayПользователи? Try to describe in more detail with what exactly the difficulties arose, so that respondents know how to concentrate their attention. - default locale