Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public string SQLlogin()
- {
- String user = textBox1.Text;
- String pass = textBox2.Text;
- String connectionString = "Data Source =.; Initial Catalog =syntic; Integrated Security =SSPI;";
- //// SqlCommand cmd = new SqlCommand("SELECT username,password FROM users WHERE username='" + textBox1.Text + "' and password='" + maskedTextBox1.Text + "'", lgnConnection);
- SqlConnection connection = new SqlConnection(connectionString);
- connection.Open();
- SqlCommand command = new SqlCommand();
- command.Connection = connection;
- command.CommandText = ("SELECT * FROM dbo.daten WHERE username='" + user + "' and passwort='" + pass + "'");
- SqlDataReader reader = command.ExecuteReader();
- if (reader.HasRows)
- {
- while (reader.Read())
- {
- String vorname = reader["vorname"] + "";
- String nachname = reader["nachname"] + "";
- String usersql = reader["Username"] + "";
- String pwsql = reader["Passwort"] + "";
- String geld_string = reader["Geld"] + "";
- int geld = Convert.ToInt32(geld_string);
- String HP_full_string = reader["HP_Full"] + "";
- int HP_full = Convert.ToInt32(HP_full_string);
- String Def_string = reader["Def"] + "";
- int Def = Convert.ToInt32(Def_string);
- String Exp_string = reader["Exp"] + "";
- int Exp = Convert.ToInt32(Exp_string);
- String spielername = reader["spielername"] + "";
- String email = reader["email"] + "";
- String HP_string = reader["HP"] + "";
- int HP = Convert.ToInt32(HP_string);
- if (textBox1.Text == usersql && textBox2.Text == pwsql)
- {
- //Neue Form !
- new Form2().Show();
- this.Hide();
- }
- else if (textBox1.Text != usersql || textBox2.Text != pwsql)
- {
- }
- }
- }
- else
- {
- MessageBox.Show("Passwort oder User falsch", "Error", MessageBoxButtons.OK);
- }
- return null;
- }
Add Comment
Please, Sign In to add comment