I am trying to create a SQL select statement that uses the LoginName or User.Identity.Name to filter the SQL statement to show only records for that user. This is just for a Time Clock DB I have on the server. I have been plagued with errors :D
These are my attempts? Can anyone point me in the right direction??
Thanks In advance -
<!--- Doesn't Work -- Works if I take "QueryStringParameter DefaultValue='" & User.Identity.Name & "' " and replace it with QueryStringParameter DefaultValue='"ACFUNDING/Administrator"
<asp:SqlDataSource ID="ACF_TimeClock_Test" runat="server" ConnectionString="<%$ ConnectionStrings:ACFTimeClock_TestConnectionString %>"
SelectCommand="SELECT employees.emp_id, employees.emp_first, employees.emp_last, employees.ad_user, timeclock.clockin, timeclock.clockout, timeclock.type FROM employees INNER JOIN timeclock ON employees.emp_id = timeclock.emp_id WHERE (timeclock.clockin BETWEEN '08/01/2008' AND '08/31/2008') AND (employees.ad_user = @USERNM)">
<SelectParameters>
<asp:QueryStringParameter DefaultValue='" & User.Identity.Name & "' Name="USERNM"
QueryStringField= '<%= User.Identity.Name %>' />
</SelectParameters>
</asp:SqlDataSource>
<!--- Also Doesn't Work but if i replace '" & User.Identity.Name & "' with "ACFUNDING/Administrator" works great haha but I need the parameter to be dynamic!!!
<asp:SqlDataSource ID="ACF_TimeClock_Test" runat="server" ConnectionString="<%$ ConnectionStrings:ACFTimeClock_TestConnectionString %>"
SelectCommand="SELECT employees.emp_id, employees.emp_first, employees.emp_last, employees.ad_user, timeclock.clockin, timeclock.clockout, timeclock.type FROM employees INNER JOIN timeclock ON employees.emp_id = timeclock.emp_id WHERE (timeclock.clockin BETWEEN '08/01/2008' AND '08/31/2008') and (employees.ad_user = '" & User.Identity.Name & "')">
</asp:SqlDataSource>