Guest User

Untitled

a guest
Oct 31st, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.78 KB | None | 0 0
  1.         public string SQLlogin()
  2.         {
  3.                 String user = textBox1.Text;
  4.                 String pass = textBox2.Text;
  5.  
  6.                 String connectionString = "Data Source =.; Initial Catalog =syntic; Integrated Security =SSPI;";
  7.                      //// SqlCommand cmd = new SqlCommand("SELECT username,password FROM users WHERE username='" + textBox1.Text + "' and password='" + maskedTextBox1.Text + "'", lgnConnection);
  8.  
  9.                
  10.                 SqlConnection connection = new SqlConnection(connectionString);
  11.            
  12.                
  13.                 connection.Open();
  14.                
  15.  
  16.                 SqlCommand command = new SqlCommand();
  17.                 command.Connection = connection;
  18.                 command.CommandText = ("SELECT * FROM dbo.daten WHERE username='" + user + "' and passwort='" + pass + "'");
  19.                 SqlDataReader reader = command.ExecuteReader();
  20.  
  21.                
  22.                 if (reader.HasRows)
  23.                 {
  24.                     while (reader.Read())
  25.                     {
  26.                    
  27.                         String vorname = reader["vorname"] + "";
  28.                         String nachname = reader["nachname"] + "";
  29.                         String usersql = reader["Username"] + "";
  30.                         String pwsql = reader["Passwort"] + "";
  31.                         String geld_string = reader["Geld"] + "";
  32.                         int geld = Convert.ToInt32(geld_string);
  33.                         String HP_full_string = reader["HP_Full"] + "";
  34.                         int HP_full = Convert.ToInt32(HP_full_string);
  35.                         String Def_string = reader["Def"] + "";
  36.                         int Def = Convert.ToInt32(Def_string);
  37.                         String Exp_string = reader["Exp"] + "";
  38.                         int Exp = Convert.ToInt32(Exp_string);
  39.                         String spielername = reader["spielername"] + "";
  40.                         String email = reader["email"] + "";
  41.                         String HP_string = reader["HP"] + "";
  42.                         int HP = Convert.ToInt32(HP_string);
  43.  
  44.  
  45.                         if (textBox1.Text == usersql && textBox2.Text == pwsql)
  46.                         {
  47.                             //Neue Form !
  48.  
  49.                             new Form2().Show();
  50.                             this.Hide();
  51.  
  52.  
  53.                         }
  54.                         else if (textBox1.Text != usersql || textBox2.Text != pwsql)
  55.                         {
  56.  
  57.                         }
  58.                       }
  59.                     }
  60.  
  61.                 else
  62.                 {
  63.                     MessageBox.Show("Passwort oder User falsch", "Error", MessageBoxButtons.OK);
  64.                 }
  65.  
  66.  
  67.                     return null;
  68.              }
Add Comment
Please, Sign In to add comment