Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE PROCEDURE UserLogin
- -- Add the parameters for the stored procedure here
- @Username varchar(50),
- @Password varchar(50)
- SET NOCOUNT ON;
- -- Insert statements for procedure here
- SELECT COUNT(*) from UserInfo where UserName=@Username AND
- Password=@Password
- END
- GO
- namespace ADOLogin.Models
- {
- public class login
- {
- // public int UserId { get; set; }
- public string UserName { get; set; }
- public string Password { get; set; }
- }
- }
- public class datacontext
- {
- public object Login(string username,string password)
- {
- SqlConnection con = new SqlConnection(@"Data
- Source=MydbSQLEXPRESS1;Initial Catalog=Practice;Integrated
- Security=True;MultipleActiveResultSets=True;Application
- Name=EntityFramework");
- SqlCommand cmd = new SqlCommand("UserLogin",con);
- cmd.CommandType = System.Data.CommandType.StoredProcedure;
- cmd.Parameters.AddWithValue("@Username", username);
- cmd.Parameters.AddWithValue("@Password", password);
- con.Open();
- int usercount = (Int32)cmd.ExecuteScalar();
- return usercount;
- }
- }
- public ActionResult Index(login obj)
- {
- datacontext db = new datacontext();
- db.Login(obj.UserName,obj.Password);
- return View();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement