Environment.UserName作为过滤器参数 [英] Environment.UserName as filter parameter
问题描述
你好,
您能解释一下为什么Environment.UserName在我的SQL查询中不起作用吗?
当我说那行不通时:
-<![CDATA[<% Response.Write(System.Environment.UserName)%>]]>
显示当前用户名:hermans5
-当我将"hermans"与''<% Response.Write(System.Environment.UserName)%>
相对时,我的sql查询工作正常,它显示任何内容...
这是我的代码:
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:
<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>
在此先感谢
最好的问候
Samuel
thanks in advance
best regards
Samuel
推荐答案
ConnectionStrings:LabAccManConnectionString %> " SelectCommand =" 冲突检测 =" =" ="span> > < /asp:SqlDataSource >
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>
在此先感谢
最好的问候
Samuel
thanks in advance
best regards
Samuel
您确定没有收到错误服务器标签不能包含<%...%>构造."
Are you sure you dont get the error "Server tags cannot contain <% ... %> constructs."
i'没有错误,我只是得到了一个没有gridview的网页
我认为它不需要脚本,但是为什么呢?
谢谢
i''ve got no error i just got a webpage without my gridview
i think it doesn''t take the script but why ?
thanks
这篇关于Environment.UserName作为过滤器参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!