Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. using System;
  2. using System.Data.SQLite;
  3. using System.Diagnostics;
  4. using System.Windows;
  5.  
  6.  
  7.  
  8. namespace WpfApplication1
  9. {
  10. /// <summary>
  11. /// Interaction logic for MainWindow.xaml
  12. /// </summary>
  13. ///
  14. /// ';insert into users (username, password) values ('kek', 'kek');select * from users where password='
  15. public partial class MainWindow : Window
  16. {
  17. public MainWindow()
  18. {
  19. InitializeComponent();
  20. }
  21.  
  22. private void button_Click(object sender, RoutedEventArgs e)
  23. {
  24. string user = username.Text;
  25. string pass = password.Text;
  26. var conn = new SQLiteConnection("Data Source=D:\\LABS\\BSUIR_labs\\6cem\\Content_Protection_Methods\\lab05\\users");
  27. conn.Open();
  28. string sql = "select * from users where username='" + user + "' and password='" + pass + "'";
  29. SQLiteCommand command = new SQLiteCommand(sql, conn);
  30. Debug.WriteLine(sql);
  31. command.ExecuteNonQuery();
  32. SQLiteDataReader reader = command.ExecuteReader();
  33. try
  34. {
  35. textBlock.Text = reader.HasRows ? "Authed" : "Auth failed";
  36. //while (reader.Read())
  37. // Debug.WriteLine("Name: " + reader["id"] + reader["username"] + reader["password"]);
  38. }
  39. catch (Exception)
  40. {
  41.  
  42. Debug.WriteLine("ups..");
  43. }
  44.  
  45.  
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement