Click here to Skip to main content
15,913,758 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I write a sql sentence with a function in it.but it does not run.the sentence is as following:
XML
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
                                   ConnectionString="<%$ ConnectionStrings:pw_ManagementConnectionString %>"
                                   SelectCommand="SELECT PAB_NAME, PAB_ID FROM PFM_ACC_BO  WHERE PAB_USER_ID=<%#GetUserID()%>"></asp:SqlDataSource>


GetUserID() is a back function
C#
protected int GetUserID()
    {
        return (int)Session["UserID"];
    }


I do not know where is the problem.the sql sentence does not work and get a error.
I need some help.thank you very much for your help. sorry for my poor english
Posted
Updated 20-Apr-11 2:56am
v2
Comments
Pr@teek B@h! 20-Apr-11 9:06am    
What's the error that you are getting?

Are you sure it's supposed to be <%#GetUserID()%> rather than <%=GetUserID()%>?

Just a thought!

-MRB
 
Share this answer
 
Comments
hkpares 20-Apr-11 10:29am    
thank you very much!
Manfred Rudolf Bihy 20-Apr-11 11:07am    
Did this solution solve you problem?
Then please accept my solution and cast a vote.
Thanks!
check if you are getting proper value in the following field:
MIDL
Session["UserID"];
 
Share this answer
 
Comments
hkpares 20-Apr-11 9:36am    
I just can not compile it.There is a compile error. and I have test that Session["UserID"] is right.
I think that the problem may lies in the sql syntax that I do not know.

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