Advertisement
Guest User

Untitled

a guest
Apr 6th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using MySql.Data.MySqlClient;
  7. using MySql.Data;
  8.  
  9. namespace epd_online
  10. {
  11.     class Program
  12.     {
  13.         public enum Options { goed, fout, onbekend };
  14.         static public Boolean Sessie;
  15.         static public string userName, passWord;
  16.         static void Main(string[] args)
  17.         {
  18.  
  19.  
  20.  
  21.  
  22.  
  23.             /* delete query */
  24.  
  25.  
  26.             //cmd = new MySqlCommand(query, conn);
  27.             //reader = cmd.ExecuteReader();
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.             //cmd = new MySqlCommand(deleteQuery, conn);
  35.             //cmd.ExecuteReader();
  36.             /*query = "SELECT * FROM users";
  37.             cmd = new MySqlCommand(query, conn);
  38.             reader = cmd.ExecuteReader();
  39.             while (reader.Read())
  40.             {
  41.                 Console.WriteLine(reader.GetString("username"));
  42.             }
  43.             */
  44.             if (Login())
  45.             {
  46.  
  47.             }
  48.             else
  49.             {
  50.                 Console.WriteLine("Wat is je gebruikersnaam?");
  51.                 userName = Console.ReadLine();
  52.                 Console.WriteLine("Wat is je password");
  53.                 passWord = Console.ReadLine();
  54.                 Console.ReadKey();
  55.             }
  56.  
  57.  
  58.         }
  59.  
  60.         static public Boolean Login()
  61.         {
  62.             MySqlCommand cmd;
  63.             MySqlDataReader reader = null;
  64.             DBclass DBclass = new DBclass();
  65.             MySqlConnection conn = DBclass.connect();
  66.             int rowCount;
  67.  
  68.  
  69.             string query = "SELECT * FROM users WHERE password='{0}' and username='{1}'", userName, passWord;
  70.  
  71.             cmd = new MySqlCommand(query, conn);
  72.             rowCount = (int)cmd.ExecuteScalar();
  73.             if (rowCount == 1)
  74.             {
  75.                 return Sessie = true;
  76.             }
  77.             else
  78.             {
  79.                 return Sessie = false;
  80.             }
  81.         }
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement