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
The Beginner's Guide to Joomla
FierceDeveloper
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!