Uploading Avatar photo error

Last post 02-02-2007 9:53 PM by mnebinger. 5 replies.

Sort Posts:

  • Uploading Avatar photo error

    03-05-2006, 5:09 PM
    • Member
      5 point Member
    • mhare
    • Member since 03-05-2006, 9:51 PM
    • Posts 1

    Has anyone come across this, and hopefully know a solution

    'NullReferenceException not handled by user code'

    this appears when i try and upload a photo in member_details.aspx.

    does anyone have any ideas, the code is similar to image fetch.aspx,

    which works fine.

     

    thanks

    Malcolm

     

     

    Public Sub writeSingleImage(ByVal MemberID As Guid, ByVal output As IO.Stream)

    'todo fix the following line of code

    Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("ClubSiteDB").ConnectionString)

    Dim qry As String = "select avatar from memberinfo where memberid=@memberid"

    Dim command As New SqlCommand(qry, connection)

    Dim param0 As New Data.SqlClient.SqlParameter("@memberid", Data.SqlDbType.UniqueIdentifier)

    param0.Value = MemberID

    command.Parameters.Add(param0)

    connection.Open()

    Dim d As Byte() = CType(command.ExecuteScalar(), Byte())

    output.Write(d, 0, d.Length)

    connection.Close()

    End Sub

  • Re: Uploading Avatar photo error

    04-14-2006, 2:27 PM
    • Member
      20 point Member
    • Woofmeister
    • Member since 04-14-2006, 6:11 PM
    • Posts 4

    I too have trouble uploading an avatar image in the Members Detail Section. I don't get an error, but I don't get an uploaded image either, just an image placeholder where the thumbnail picture should be. No avatar image displayed in "Members" section of site at all.

    I wish I had more to contribute but I'm a Newbie to all this and stumbling around in the dark a lot. I hope someone can resolve this as I'd like to paste some animal pictures to the hockey team I placed this site for. Some motivation eh!

    Rick

  • Re: Uploading Avatar photo error

    04-14-2006, 8:31 PM
    • Participant
      1,910 point Participant
    • aabruzzese
    • Member since 09-28-2005, 7:40 PM
    • Montreal, QC
    • Posts 464

    are you getting an error even with an Image selected in the browse files control?

    I get an error only when I do not select a pic, I do believe the code does not check for null values.

    I you hit the clearimage button you get the PlaceHolder showing a blank square.

     

    AngeloA
  • Re: Uploading Avatar photo error

    04-14-2006, 9:04 PM
    • Member
      10 point Member
    • LFBates
    • Member since 04-15-2006, 12:07 AM
    • Posts 2

    I am having the same issue, clearing the image nulls the avatar data field in memberinfo and sets to the no photo image, when I uploadimage_click with testavatar.jpg the table shows a binary value in the avatar field so I am assuming it's loading correctly.

    I got the nullref error as well, but got past that by changing the byte array declaration line to this

    byte

    [] d = (byte[])Convert.ChangeType(command.ExecuteScalar(), Type.GetType("byte[]"));

    problem is I think the Changetype is return a null argument exception

    I know just enough C# to be dangerous, and can't seem to get past this.

    I tried not casting it and got an invalid cast from sqlbinary to byte[], I am sure thisis something silly i am missing, any help would be appreciated.

  • Re: Uploading Avatar photo error

    04-16-2006, 2:13 PM
    • Member
      10 point Member
    • LFBates
    • Member since 04-15-2006, 12:07 AM
    • Posts 2

    Got it to work, changed the delaration line to this.

     byte[] d = (byte[])Convert.ChangeType(command.ExecuteScalar(), typeof(byte[]));

    I hope this helps someone else like me.

  • Re: Uploading Avatar photo error

    02-02-2007, 9:53 PM
    • Member
      18 point Member
    • mnebinger
    • Member since 02-02-2007, 9:51 PM
    • Posts 9

    I made a simple change to Member_Details.aspx at the beginning of uploadimage_Click

    If newavatar.HasFile = False Then Return
     
Page 1 of 1 (6 items)