Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Data.OleDb;
- using System.Linq;
- using System.Web;
- using System.Web.Services;
- namespace LoginService
- {
- /// <summary>
- /// Summary description for LoginService
- /// </summary>
- [WebService(Namespace = "http://tempuri.org/")]
- [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
- [System.ComponentModel.ToolboxItem(false)]
- // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
- // [System.Web.Script.Services.ScriptService]
- public class Login : System.Web.Services.WebService
- {
- string CONNECTION_STRING = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|login.accdb;Persist Security Info=True";
- [WebMethod]
- public User DoLogin(string username, string password)
- {
- try
- {
- string query = "SELECT TOP 1 * FROM tblUsers WHERE Username=\"{0}\" AND Password=\"{1}\"";
- query = string.Format(query, username, password);
- OleDbConnection dbConn = new OleDbConnection(CONNECTION_STRING);
- OleDbCommand dbCmd = new OleDbCommand(query, dbConn);
- dbConn.Open();
- OleDbDataReader reader = dbCmd.ExecuteReader();
- reader.Read();
- User u = new LoginService.User(reader);
- dbConn.Close();
- return u;
- }
- catch
- {
- return new LoginService.User();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement