|
-
May 9th, 2004, 03:51 PM
#1
Thread Starter
Lively Member
Dbnull
Hi,
I am trying to return a URL for a picture based on the file path (which is just an nvarchar value from my DB). This works fine when there are no nulls however in reality when the system is operational there will be nulls so I need it to be able to cope with this. I thought this should be an easy fix but none of the solutions I've seen to similar problems on this forum work! The line of code I have is:
Private Sub Page_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.DataBinding
Dim dr As DataRow
dr = Me.Dsplayers.View_Player_Stats.DefaultView(Position).Row
Me.TextBox1.Text = DataBinder.Eval(dr, "Player_ID")
Me.TextBox3.Text = DataBinder.Eval(dr, "Player_Name")
Me.Image3.ImageUrl = DataBinder.Eval(dr, "Photo_Path")
If anyone has any ideas please let me know!
-
May 9th, 2004, 05:37 PM
#2
Frenzied Member
1) Databases should never contain NULL's in a field. You should always set a default value for the field.
2) Check for DBNull...More info from MSDN
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
May 10th, 2004, 07:24 AM
#3
Thread Starter
Lively Member
As a general rule maybe, but I don't have a photo for everyone, so if I put in a default URL surely this would bring up an error, unless I suppose it pointed to a blank default picture. Incidentally what I've done for the moment is amended the query itself so that each field is part of an isnull statement ie. isnull(photo_path,'') as Photo_Path which seems to return what I was hoping.
-
May 10th, 2004, 08:08 AM
#4
Frenzied Member
If it's a varchar or nvarchar field, then the default value should just be ('') an empty string.
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
-
May 10th, 2004, 08:14 AM
#5
Thread Starter
Lively Member
Yeah its an nvarchar field, so I can give that a go and see what happens. Cheers for the advice.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|