user1024416
user1024416

Reputation: 145

Turning a string in to a reference of an object

I'm trying to create a dynamic stored procedure from a database. The parameters for the stored procedure are select from another stored procedure.

I need to be able to reference a session object for example from a string held within a database field.

How do I turn a string into a reference to the Session object. For example:

cmd.Parameters.Add(new SqlParameter("@test", rdr["fldValue"].ToString()));

The value of fldValue is "Session["SessionParam"].ToString()"

What I would like is to be turn the string into a reference of an object so I would get the following:

cmd.Parameters.Add(new SqlParameter("@test", Session["SessionParam"].ToString()));

I would like to reference the value of any object but am looking at the Session object initially.

Any help would be greatly appreciated.

Upvotes: 0

Views: 66

Answers (1)

Vidhya Sagar Reddy
Vidhya Sagar Reddy

Reputation: 1631

Try using:

cmd.Parameters.Add("@test", Session["SessionParam"].ToString());

Upvotes: 1

Related Questions