Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have a scenario where i have made a web page of update user, in which i want to put data of a specific user in grid view using sql data source. The id of specific user comes from session, but there is a problem that
C#
AppUserID = Convert.ToInt32(Session["AppUserID"]);


But in the database table the user id is of int type,

Now the sql expression becomes
SQL
[UserId] = @UserID and its Value is Session("AppUserID")


Now here, it gives the error of mismatch datatype.
Posted
Updated 19-Apr-14 22:32pm
v3
Comments
Where exactly it gives the issue?
Muhammad Taqi Hassan Bukhari 20-Apr-14 4:56am    
When i click on Test Query it raise up an error message that @UserID have wrong datatype or it is mismatched.
And what is that query? Where are you testing?

1 solution

you could write a method like this and should work. But without the query your are testing its hard to tell
C#
public int AppUserID
   {
       get
       {
           object AppUserID= Session["AppUserID"] as object;
           if (AppUserID == null)
           {
               int AppUserID= -1;
               return AppUserID;
           }
           else
               return AppUserID== null ? null : AppUserID as int;
       }
       set
       {
           Session["AppUserID"] = value;
       }
   }
 
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