sessions and c# error


i have a strange error i am trying to setup a look to create sessions on teh fly from my dayabase but i get an error stateing that i cant use session like a method.

        public void Get_System_Sertup()
            SqlCommand sql = new SqlCommand();
            SqlConnection conn = default(SqlConnection);
            Connect ORC = new Connect();
            SqlDataReader dr = default(SqlDataReader);
            // set some ghost variables for the system setup 
            string Value = "";
            string SystemValue = "";

            // *****
            // ***** Connect to database
            // *****
            conn = ORC.NewSQLConnectionWebAppT();
            sql.Connection = conn;

            // setup the sql action to insert update or delete using parameterized data
            sql.Parameters.AddWithValue("@VALUE", "Y");

            // *****
            // ***** Get system data from server
            // *****
            sql.CommandText = "SELECT System,SystemValue FROM " + dbPrefix + "_System_Settings WHERE Valid = '@VALUE'";
            dr = sql.ExecuteReader();

            // gets The values form the database to display to The user
            while (dr.Read())
                Value = Convert.ToString(dr["System"]);
                SystemValue = Convert.ToString(dr["SystemValue"]);
                HttpContext.Current.Session(Convert.ToString(Value)) = SystemValue;
                // sets sessions on the fly

            // *****
            // ***** Close Database
            // *****


Open in new window

Error	2	Non-invocable member 'System.Web.HttpContext.Session' cannot be used like a method.	I:\Synamics\Synamics\SystemInternals.cs	60	37	Synamics

Open in new window

Chris JonesLead Application Web DeveloperAsked:
Who is Participating?
käµfm³d 👽Connect With a Mentor Commented:
Don't use parentheses when indexing the Session object--use brackets:

HttpContext.Current.Session[Convert.ToString(Value)] = SystemValue;

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.