Advertisement
Guest User

login

a guest
Jul 30th, 2011
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Services;
  8. using System.Web.Services.Protocols;
  9. using System.Xml.Linq;
  10. using System.Data.SqlClient;
  11.  
  12. namespace LoginDetails
  13. {
  14. /// <summary>
  15. /// Summary description for Service1
  16. /// </summary>
  17. [WebService(Namespace = "http://tempuri.org/")]
  18. [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  19. [ToolboxItem(false)]
  20. // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
  21. // [System.Web.Script.Services.ScriptService]
  22. public class Service1 : System.Web.Services.WebService
  23. {
  24.  
  25. SqlConnection myConnection = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=student;User ID=sa;Password=123");
  26. [WebMethod]
  27. public String GetLoginDetails(string UserName, string Password)
  28. {
  29.  
  30.  
  31. try
  32. {
  33. myConnection.Open();
  34.  
  35. SqlCommand myCommand = new SqlCommand();
  36. myCommand.Connection = myConnection;
  37. myCommand.CommandText = "select * from Login where UserName = '" + UserName + "' and Password='" + Password + "'";
  38.  
  39.  
  40. SqlDataReader myReader = myCommand.ExecuteReader();
  41.  
  42.  
  43. }
  44. catch (Exception ex)
  45. {
  46. Console.WriteLine(ex.Message);
  47. }
  48. finally
  49. {
  50. myConnection.Close();
  51. }
  52.  
  53. return "success";
  54.  
  55.  
  56.  
  57. }
  58.  
  59. }
  60.  
  61.  
  62.  
  63.  
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement