AspdotnetCodes.com
Search
Articles
Books
Resources
Asp.Net News
Downloads
Free Tech Magazines
Asp.Net Web Hosting
Archives
Softwares
Newsletter
Suggest Us
Link to Us
Feeds Subscription
Articles
Questions & Answers
Tips & Tricks
 Use more than one Session Variable in a command parameter.
Posted by Nannab on  3/11/2011 10:01:53 PM Category: ADO.NET
Add to my favorites
Email to friend
Using Visual Studio 2008

Is it possible to do an if logic in command parameter???
current code
command.Parameters.Add("@MyCurrUserId", DB2DbType.Char, 8).Value = Session("ManagerID");

I need to use two others Session("prevPage")= "managerpage" and Session(CurrUserId")
I am not sure how the syntax should go.

This is my attempt any help would be appreciated. The help in the code behind is not giving me a clear error.

command.Parameters.Add("@MyCurrUserId", DB2DbType.Char, 8).Value = If(Session("prevPage)= "managerpage") then Session("ManagerID")
else Session("CurrUserId")

Post Your Reply Post New Question

 Viewer's Reply
Conditional SqlCommad
Answered By Moderator1 on 3/11/2011 10:09:06 PM
Hi,

Try this logic

If Session("prevPage).ToString() = "managerpage" then
command.Parameters.Add("@MyCurrUserId", DB2DbType.Char, 8).Value = Session("ManagerID")
Else
command.Parameters.Add("@MyCurrUserId", DB2DbType.Char, 8).Value = Session("CurrUserId")
End IF
 
Post Your Reply If you still have problem, post it again under this reply for better response.

 
Sponsored by
Sexy Web Design - Free 71 Page Preview!
Everything You Know About CSS Is Wrong! - Free 37 Page Preview!
When Good HTML Goes Bad: How You Can Protect Your Web Applications