Last post Feb 02, 2007 09:53 PM by mnebinger
Mar 05, 2006 05:09 PM|mhare|LINK
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.
Public Sub writeSingleImage(ByVal MemberID
As Guid, ByVal output
'todo fix the following line of code
As New SqlConnection(ConfigurationManager.ConnectionStrings("ClubSiteDB").ConnectionString)
Dim qry As
String = "select avatar from memberinfo where memberid=@memberid"
As New SqlCommand(qry, connection)
Dim param0 As
New Data.SqlClient.SqlParameter("@memberid", Data.SqlDbType.UniqueIdentifier)
param0.Value = MemberID
Dim d As
Byte() = CType(command.ExecuteScalar(),
output.Write(d, 0, d.Length)
Apr 14, 2006 02:27 PM|Woofmeister|LINK
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!
Apr 14, 2006 08:31 PM|aabruzzese|LINK
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.
Apr 14, 2006 09:04 PM|LFBates|LINK
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
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.
Apr 16, 2006 02:13 PM|LFBates|LINK
Got it to work, changed the delaration line to this.
byte d = (byte)Convert.ChangeType(command.ExecuteScalar(),
I hope this helps someone else like me.
Feb 02, 2007 09:53 PM|mnebinger|LINK
I made a simple change to Member_Details.aspx at the beginning of uploadimage_Click
If newavatar.HasFile = False Then Return