I am developing a little ASP MVC Project without Entity Framework.

In order to show the name of the logged user in my page near Welcome (Example "Welcome John")I want to retrieve the values of the attribute "Email" from the table "Client" and store it in a List "result" and then compare each Email of this List with X (which is the logged Email). 

In case of equality, I retrieve the corresponding "LastName" to this Email and store in a variable y. 

In the End, I allocate y to the value of my Session. But I got always this error :

**ExecuteReader: Connection property has not been initialized**

I am sorry for the quality of coding,please consider that I am beginner.

This what I tried :

in **Controller** :

```
  private void connection()
    {
        string constring = ConfigurationManager.ConnectionStrings["DeliveryCon"].ToString();
        con = new SqlConnection(constring);
    }

    public ActionResult Login()
        {
            return View();
        }

    database_Access_layer.db dblayer = new database_Access_layer.db();

    [HttpPost]
     public ActionResult Login(FormCollection fc, string LastName, string Email)
    {
        int res = dblayer.Admin_Login(fc["Email"], fc["Password"]);
        if (res == 1)
        {
            Session["currentUser"] = Email;
            string z = Email;
            connection();
            con.Open();
            SqlCommand command = new SqlCommand("select Email from Client", con);

            List<string> result = new List<string>();
            using (var reader = command.ExecuteReader())
            {
                while (reader.Read())
                    result.Add(reader.GetString(0));
            }
            foreach (string x in result)
            {
                if (x == z)
                {

                    SqlCommand command2 = new SqlCommand("select LastName from Client WHERE Email= @x ", con);
                    //con.Open();
                    SqlParameter param = new SqlParameter( "@x", SqlDbType.NVarChar, 16);
                    param.Value = Session["currentUser"];
                    command2.Parameters.Add(param);
                    //con.Open();
                    string y = command2.ExecuteScalar().ToString();
                    con.Close();
                    Session["currentUser"] = y;

                }
            } 
            return RedirectToAction("Create", "Client");
            Session.RemoveAll();

        }
        else {

            TempData["msg"] = " Email or Password is wrong !";
            return RedirectToAction("Index", "Home");

        }

    }

```

In **my View Create.cshtml :**

```
<h4>Welcome @if (Session["currentUser"] != null)
{ <h4> @Session["currentUser"].ToString()</h4>}</h4>

```