1

Here i am using MVC4 razor and stored procedure.Here i am trying to retrieve userid and usertype from sp (retrieving as a objec) ,but i am getting null value for tabledata variable .How could i get userid and usertype for that particular username and password,please help me i am new to MVC

Homecontroller.cs

[HttpPost]
    [AllowAnonymous]
    [ValidateAntiForgeryToken]
    public ActionResult Login(logintable p)
    {
        OnlineAppraisalEntities db = new OnlineAppraisalEntities();

        logintable tabledata = new logintable();

        tabledata = db.sp_Userlogindata(p.Username, p.Password);

        return View(p);
    }

Stored procedure

 ALTER PROCEDURE [dbo].[sp_Userlogindata]
-- Add the parameters for the stored procedure here

@Username varchar(30),
@Password varchar(30)
AS

BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
select Usertype,UserID from logintable where Username=@Username and     Password=@Password

END
allDroid
  • 405
  • 1
  • 10
  • 21
  • Your `tabledata` variable may contain the data but you don't do anything with it (all you doing is returning the original data you posted) –  Nov 25 '15 at 10:06
  • Also You need to Import the stored procedure as a Function. Check this:http://stackoverflow.com/a/32359095/2946329 – Salah Akbari Nov 25 '15 at 10:07
  • @Stephen Muecke here all i need is to get userid and usertype to valid username and password,then on getting this i will pass this to other actionresult in same controller as a parameter. – allDroid Nov 25 '15 at 10:28

0 Answers0