Advertisement
Guest User

Untitled

a guest
May 25th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows.Forms;
  5. using System.Data.Sql;
  6. using System.Data.SqlClient;
  7.  
  8. namespace WindowsFormsApplication1
  9. {
  10. static class Program
  11. {
  12. /// <summary>
  13. /// The main entry point for the application.
  14. /// </summary>
  15. [STAThread]
  16. static void Main(string[] args)
  17. {
  18.  
  19. string conectionstring = "Data Source=174.121.133.226;Initial Catalog=cstott_login;User Id=cstott_login;Password=n";
  20. SqlConnection connection = new SqlConnection(conectionstring);
  21. try
  22. {
  23. connection.Open();
  24. Console.WriteLine("Connection Open");
  25. }
  26. catch (Exception e)
  27. {
  28. Console.WriteLine(e);
  29. Console.Read();
  30. }
  31. Console.WriteLine("Username> ");
  32. string username = Console.ReadLine();
  33. Console.WriteLine("Password> ");
  34. string password = Console.ReadLine();
  35. SqlCommand command = new SqlCommand("SELECT * FROM [login] WHERE Username='" + username + "' AND Password='" + password + "'", connection);
  36. SqlDataReader reader = null;
  37. reader = command.ExecuteReader();
  38. while (reader.Read())
  39. {
  40. Console.WriteLine("Welcome: " + reader["username"].ToString());
  41. Console.Read();
  42.  
  43. }
  44. Console.WriteLine("User: " + username + "does not exist");
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement