Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.59 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.OleDb;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.Services;
  7.  
  8. namespace LoginService
  9. {
  10.     /// <summary>
  11.     /// Summary description for LoginService
  12.     /// </summary>
  13.     [WebService(Namespace = "http://tempuri.org/")]
  14.     [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  15.     [System.ComponentModel.ToolboxItem(false)]
  16.     // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
  17.     // [System.Web.Script.Services.ScriptService]
  18.     public class Login : System.Web.Services.WebService
  19.     {
  20.         string CONNECTION_STRING = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|login.accdb;Persist Security Info=True";
  21.         [WebMethod]
  22.         public User DoLogin(string username, string password)
  23.         {
  24.             try
  25.             {
  26.                 string query = "SELECT TOP 1 * FROM tblUsers WHERE Username=\"{0}\" AND Password=\"{1}\"";
  27.                 query = string.Format(query, username, password);
  28.                 OleDbConnection dbConn = new OleDbConnection(CONNECTION_STRING);
  29.                 OleDbCommand dbCmd = new OleDbCommand(query, dbConn);
  30.                 dbConn.Open();
  31.                 OleDbDataReader reader = dbCmd.ExecuteReader();
  32.                 reader.Read();
  33.                 User u = new LoginService.User(reader);
  34.                 dbConn.Close();
  35.                 return u;
  36.             }
  37.             catch
  38.             {
  39.                 return new LoginService.User();
  40.             }
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement