Re: Ajax Uploader and logged in user

  •  07-26-2008, 10:58 AM

    Re: Ajax Uploader and logged in user

    Thanks for the reply Adam. Maybe I can do a better job explaining my issue:
     
    I am using the Ajax Uploader in a custom solution.  I do not need to change the filename, I just need to pass
    the currently logged in user id (from membership) to AJAX Uploader. I want to populate the UserId column in the UploaderFiles SQL Table with the currently logged in user (logged in through asp.net membership).
     
    Specifically referring to the below bit of code in SampleDB.vb. It always comes back as Guest.  Is it because there isn't a "CurentUserRow" in "Context.Items" (I see a 'user' item but no 'CurentUserRow' when I debug)? Perhaps this is a typo in the SampleDB code?
     
    I wanted to make sure there wasn't an 'easy' way to do this before going in and changing things.
     
    Thanks for your help Adam!

    Public Shared Function GetCurentUserRow() As DataRow

    Dim row As DataRow = DirectCast(Context.Items("CurentUserRow"), DataRow)      <----- is there a typo in this line???

    If row IsNot Nothing Then

    Return row

    End If

    Dim username As String = "Guest"

    row = ExecuteDataRow("SELECT * FROM UploaderUsers WHERE Username={0}", username)

    If row Is Nothing Then

    Dim userid As Integer = ExecuteInt32("INSERT UploaderUsers (UserName) VALUES ({0}) SELECT SCOPE_IDENTITY()", username)

    row = ExecuteDataRow("SELECT * FROM UploaderUsers WHERE UserId={0}", userid)

    End If

    Context.Items("CurentUserRow") = row

    Return row

    End Function

View Complete Thread