Author: nlehman | Posted on: 11/26/2009 12:06:37 PM | Views : 273

Hi,
I have a role provider set up on my site.  I need to use the username form the current user as a parameter for an sqldatasource.  I have done it many times using an objectdatasource with my strong typed dataset, but I can't figure out how to pass the username as a parameter to a plain sqldatasource.   I am assigning the my.user,name to a variable called 'username'. Here is my current try which doesn't work:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT  DISTINCT q.*
FROM QuoteMain q, Users u
WHERE u.ShowAllCustomers=1 and u.ShowSpecialCharges=1 and u.UserName=@username
ORDER BY q.MainQuoteNum DESC">

<SelectParameters>
     <asp:Parameter Name="@username" Type="String" />
</SelectParameter ...

Go to the complete details ...