Store multiple values in a session variable

Posted by user458790 on Stack Overflow See other posts from Stack Overflow or by user458790
Published on 2011-01-09T09:43:42Z Indexed on 2011/01/09 9:53 UTC
Read the original article Hit count: 182

Filed under:
|
|

Hi,

Before I ask my doubt, please consider this scenario that a user on my website have a profileID. With this profileID are associated some pluginID's. For eg: User1 might have 2, 3 and 5 plugins associated with its profile.

When the user logs in, I store the profileID of the user in a session variable cod. At a certain page, the user tries to edit the plugins associated with his profile. So, on that page, I have retrieve those pluginID's from the DB.

I have applied this code but this fetches only the maximum pluginID from the DB and not all the pluginID's.

SqlCommand cmd1 = new SqlCommand("select plugin_id from profiles_plugins where id=(select id from profiles_plugins where profile_id=" + Convert.ToInt32(Session["cod"]) + ")", con);
        SqlDataReader dr1 = cmd1.ExecuteReader();
        if (dr1.HasRows)
        {
            while (dr1.Read())
            {
                Session["edp1"] = Convert.ToInt32(dr1[0]);

            }
        }
        dr1.Close();
        cmd1.Dispose();

I was trying to figure out how can I store multiple pluginID's in this session variable? Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET