Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
I am getting error in the second line. Please suggest.

C#
Int64 UsrId = (Int64)ht["UserID"];
string CreatedBy = UsrId;Convert.ToInt32(Convert.ToString(Session["UserID"]).Trim());



How can I solve this error? Please suggest how can I change the logic here
Posted
Updated 18-Aug-15 21:15pm
v2
Comments
Mayank Vashishtha 19-Aug-15 3:18am    
You need to provide more information. Although it's the first line of your code which is making trouble. Have you checked what type of value is there in ht["UserID"]?
Member 9017207 19-Aug-15 3:19am    
UserID takes bigint

Quote:
string CreatedBy = UsrId
Should be
C#
string CreatedBy = UsrId.ToString();

or (better)
C#
string CreatedBy = ht["UserID"];



Quote:
Convert.ToInt32(Convert.ToString(Session["UserID"]).Trim());
The above line makes no sense to me. What's its purpose?
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 19-Aug-15 3:22am    
5ed.
(And I can tell you the purpose: Unhappy Inquirer or Is the Abuse the Main Purpose of Programming? :-)
—SA
It's simple then. change the line 2 to
C#
string CreatedBy = UsrId.ToString();
 
Share this answer
 
C#
Int64 UsrId = (Int64)ht["UserID"];
string CreatedBy = UsrId;Convert.ToInt32(Convert.ToString(Session["UserID"]).Trim());


Simply:
C#
string CreatedBy = Convert.ToString(UsrId);
OR
string CreatedBy = ht["UserID"];

will work
Hope it Helps :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900