public ActionResult list(MvcApplication1.Models.LoginDetails model) { using (var con = new SqlConnection (ConfigurationManager.ConnectionStrings["con"].ConnectionString)) { var cmd = new SqlCommand("sp_select_data", con); // here use Select Procedure cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@UserName", SqlDbType.VarChar)).Value = model.UserName.Trim();//Pass the parameter cmd.Parameters.Add(new SqlParameter("@LoginId", SqlDbType.VarChar)).Value = model.LoginID.Trim();//Pass the parameter cmd.Parameters.Add(new SqlParameter("@Password", SqlDbType.VarChar)).Value = model.Password; //Pass the parameter con.Open(); DataSet logininfo = new DataSet(); SqlDataAdapter dataAdptr = new SqlDataAdapter(cmd); dataAdptr.Fill(logininfo); dataAdptr.Dispose(); DataTable Loginfinfotable = new DataTable(); Loginfinfotable = logininfo.Tables[0]; List<DataRow> obj = new List<DataRow>(); //List<DataRow> obj = Loginfinfotable.AsEnumerable().ToList(); foreach (DataRow dr in Loginfinfotable.Rows) { obj.Add(dr); } return View("LoginDetails", obj); //return View(Loginfinfotable); } //return View(); }
Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 90: Line 91: <table> Line 92: @foreach (var item in Model) { Line 93: <tr> Line 94: <td>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)