none
SqlDataSource & Parameters RRS feed

  • Question

  • I'm updating some code written by a previous developer, and I'm not sure how this works.

    <asp:SqlDataSource ID="SqlDataSourceCompanies" runat="server" ConnectionString="<%$ ConnectionStrings:cs_ %>"
      SelectCommand="SELECT CompanyID, NameAndType FROM udf_CompanyByAppUser(@AppUserName, 'INS') ORDER BY [Name]">
        <SelectParameters>
           <asp:Parameter Name="AppUserName" />
         </SelectParameters>
      </asp:SqlDataSource>
    No where is AppUserName set a value, not in session variable, or in code behind. However, I run SQL Profiler to see what it sends, and it sends the name I am authenticated with under the webapp.

    Is this variable a special parameter under asp.net? Sorry if this is wrong section!
    Thursday, January 7, 2010 1:56 PM

Answers

  • I have not been able to find anything about AppUserName being a special parameter.
    Also, I would expect a value, datatype, direction etc. for a paramter.

    "Using Parameters with the SqlDataSource Control"
    http://msdn.microsoft.com/en-us/library/z72eefad.aspx

    One thing could be that the backing function/stored procedure is collecting the authenticated name when it gets an empty parameter?

    Pseudocode.
        if (appuser equals NULL) then
             use currentuser
         end if

    Just a thought.
    //Michael
    This posting is provided "AS IS" with no warranties.
    • Marked as answer by Kbalz Wednesday, January 12, 2011 9:54 PM
    Thursday, January 7, 2010 3:54 PM

All replies

  • I have not been able to find anything about AppUserName being a special parameter.
    Also, I would expect a value, datatype, direction etc. for a paramter.

    "Using Parameters with the SqlDataSource Control"
    http://msdn.microsoft.com/en-us/library/z72eefad.aspx

    One thing could be that the backing function/stored procedure is collecting the authenticated name when it gets an empty parameter?

    Pseudocode.
        if (appuser equals NULL) then
             use currentuser
         end if

    Just a thought.
    //Michael
    This posting is provided "AS IS" with no warranties.
    • Marked as answer by Kbalz Wednesday, January 12, 2011 9:54 PM
    Thursday, January 7, 2010 3:54 PM
  • Is it possible that the value is being set by it's orginal position (e.g. 0) and not by the parameter name? Is there any reference to the SqlDataSourceCompanies SelectParameters in code?
    Paul ~~~~ Microsoft MVP (Visual Basic)
    Thursday, January 7, 2010 6:20 PM
  • Nope no references in code at all. I've done a full search on text on the solution for AppUserName  it only returns four times, two on this example, and two on a similar example where it is used. The site is using Forms authentication. The SQL Profiler shows a different 'AppUserName' being sent to the sql function, everytime I log on to the web app as a different user.

    I guess the best way for me to investigate is to start a new web app and database, and try some simple transaction like this, maybe it is something special that no one knows about!

    Thanks for your responses, I'll post later if I can try it out.
    Friday, January 8, 2010 2:09 PM
  • Hello,

    How is the problem now?  


    Best Regards,
    Lingzhi Sun
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Tuesday, January 12, 2010 10:54 AM
    Moderator