Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,

could you explain me why Environment.UserName doesn't work in my SQL query ?
when i would say that doesn't work:
- <![CDATA[<% Response.Write(System.Environment.UserName)%>]]> displays the current username : hermans5

-my sql query works fine when i put 'hermans' contrary to '<% Response.Write(System.Environment.UserName)%> its displays anything...

here my code:
XML
<asp:SqlDataSource ID="SqlDataSource1" runat="server" EnableCaching="True" FilterExpression="genacc_user_adacc = '<% Response.Write(System.Environment.UserName)%>'" ConnectionString="<%$ ConnectionStrings:LabAccManConnectionString %>"        SelectCommand="with cteDataList
as
(
SELECT account_user.genacc_user_adacc, genacc_machines.hostname, genacc_account.SPE, genacc_account.adacc, genacc_account.department,
   genacc_machines.software, genacc_machines.location, genacc_pw.pass, genacc_pw.key_index,
   row_number() over (PARTITION by account_user.genacc_user_adacc, genacc_machines.hostname order by genacc_pw.id desc) as Rown
FROM  genacc_pw INNER JOIN
   genacc_account ON genacc_pw.genacc_account_id = genacc_account.id INNER JOIN
   account_user ON genacc_account.id = account_user.genacc_account_id INNER JOIN
   genacc_machines ON genacc_account.id = genacc_machines.genacc_account_id
)
Select * from cteDataList
where RowN = 1
"ConflictDetection="CompareAllValues"></asp:SqlDataSource>

thanks in advance
best regards
Samuel
Posted
Updated 5-May-10 3:23am
v2

Are you sure you dont get the error "Server tags cannot contain <% ... %> constructs."
 
Share this answer
 
i've got no error i just got a webpage without my gridview
i think it doesn't take the script but why ?

thanks
 
Share this answer
 
Comments
4277480 5-May-10 11:56am    
I created a quick example and included what you said however I get this http://tinyimage.net/image-AA22_4BE194B6.jpg I am not sure how the debugger is not showing it to you?

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