Guest User

Untitled

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