Last post Dec 04, 2014 02:18 AM by Archer Wang
None
0 Points
99 Posts
Dec 02, 2014 03:22 PM|mcfarlandparkway|LINK
Hello,
I have 2 pages one is aspx.cs and another is ashx page.
In the very frist page i am getting userid from session and in ashx i am retreving it.like below
aspx.cs page
Session["UserID"] = UserID;
In ashx page i have stored procedure where i am updating the records for this stored procedure i need to pass session value
string sessionValue = context.Session["UserID"].ToString();
here in sessionValue i will get id of the user.
when comming to stored procedure method how can i get this value here in @lastupdatedby paramter?
if (forms["oper"].ToString() == "edit")
{
cmd.Parameters.AddWithValue("@lastupdatedby",--- );
cmd.Parameters.AddWithValue("@AID", forms["SAID"].ToString());
I tried creating a function but still not getting.
public
string getsessiondata(HttpContext sessionValue)
{string sessionValue1 = sessionValue.Session["UserID"].ToString();
return sessionValue1;
}
Any help.......
Contributor
5642 Points
944 Posts
Dec 04, 2014 02:18 AM|Archer Wang|LINK
Hi mcfarlandparkway,
Based on your post, I suggest you could try this code as below.
cmd.Parameters.AddWithValue("@lastupdatedby", Session["UserID"]);
Here is a similar case, you may refer to it.
http://forums.asp.net/t/2005155.aspx?Stored+Procedure+And+Session
Best regards,
Archer Wang
None
0 Points
99 Posts
issue with passing session value to stored procedure paramter
Dec 02, 2014 03:22 PM|mcfarlandparkway|LINK
Hello,
I have 2 pages one is aspx.cs and another is ashx page.
In the very frist page i am getting userid from session and in ashx i am retreving it.like below
aspx.cs page
Session["UserID"] = UserID;
In ashx page i have stored procedure where i am updating the records for this stored procedure i need to pass session value
string sessionValue = context.Session["UserID"].ToString();
here in sessionValue i will get id of the user.
when comming to stored procedure method how can i get this value here in @lastupdatedby paramter?
if (forms["oper"].ToString() == "edit")
{
cmd.Parameters.AddWithValue("@lastupdatedby",--- );
cmd.Parameters.AddWithValue("@AID", forms["SAID"].ToString());
I tried creating a function but still not getting.
public
string getsessiondata(HttpContext sessionValue)
{string sessionValue1 = sessionValue.Session["UserID"].ToString();
return sessionValue1;
}
}
Any help.......
Contributor
5642 Points
944 Posts
Re: issue with passing session value to stored procedure paramter
Dec 04, 2014 02:18 AM|Archer Wang|LINK
Hi mcfarlandparkway,
Based on your post, I suggest you could try this code as below.
Here is a similar case, you may refer to it.
http://forums.asp.net/t/2005155.aspx?Stored+Procedure+And+Session
Best regards,
Archer Wang