Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: handling database Null values when assigning DB values to a labels text property


Message #1 by "Nick Charlesworth" <nick@f...> on Tue, 28 May 2002 15:01:04
I am creating a data set and trying to assign values from a database 
record in the dataset to the .text property of some label controls.

This works fine when the dataset field holds a value but when the field 
holds a Null value it is throwing an error as you can't assign a Null 
value to the text property of a label control.

How do I get round this? I have tried the following methods but none work

a) If Not IsNull(objDS("strEmail")) Then lblEmail.Text = objDS("strEmail")

b) If objDS("strEmail") <> "" Null Then lblEmail.Text = objDS("strEmail")

c) If Len(objDS("strEmail")) > 0 Then lblEmail.Text = objDS("strEmail")

thanks,

Nick
Message #2 by Colin.Montgomery@C... on Tue, 28 May 2002 15:08:37 +0100
I imagine you'll have to do something like this:

If Not IsNull(objDS("strEmail")) Then
	lblEmail.Text = objDS("strEmail")
Else
	lblEmail.Text = "No email entered"
End If

HTH,
Col

-----Original Message-----
From: Nick Charlesworth [mailto:nick@f...]
Sent: 28 May 2002 16:01
To: aspx_beginners
Subject: [aspx_beginners] handling database Null values when assigning
DB values to a labels text property


I am creating a data set and trying to assign values from a database 
record in the dataset to the .text property of some label controls.

This works fine when the dataset field holds a value but when the field 
holds a Null value it is throwing an error as you can't assign a Null 
value to the text property of a label control.

How do I get round this? I have tried the following methods but none work

a) If Not IsNull(objDS("strEmail")) Then lblEmail.Text = objDS("strEmail")

b) If objDS("strEmail") <> "" Null Then lblEmail.Text = objDS("strEmail")

c) If Len(objDS("strEmail")) > 0 Then lblEmail.Text = objDS("strEmail")

thanks,

Nick


*******

This message and any attachment are confidential and may be privileged or otherwise protected from disclosure.  If you are not the
intended recipient, please telephone or email the sender and delete this message and any attachment from your system.  If you are
not the intended recipient you must not copy this message or attachment or disclose the contents to any other person.

For further information about Clifford Chance please see our website at http://www.cliffordchance.com or refer to any Clifford
Chance office.

Message #3 by "Thea Burger" <theab@l...> on Tue, 28 May 2002 17:12:12 +0200
Hi, Nick

I had the same problem and this worked for me:

If TypeOf (qryReader("PowerwebID")) Is DBNull Then
   lblMemNr.Text = "N/A"
Else
   lblMemNr.Text = qryReader("PowerwebID")
End If

HTH,
Thea

-----Original Message-----
From: Nick Charlesworth [mailto:nick@f...]
Sent: 28 May 2002 03:54
To: aspx_beginners
Subject: [aspx_beginners] handling database Null values when assigning
DB values to a labels text property


I am creating a data set and trying to assign values from a database
record in the dataset to the .text property of some label controls.

This works fine when the dataset field holds a value but when the field
holds a Null value it is throwing an error as you can't assign a Null
value to the text property of a label control.

How do I get round this? I have tried the following methods but none work

a) If Not IsNull(objDS("strEmail")) Then lblEmail.Text = objDS("strEmail")

b) If objDS("strEmail") <> "" Null Then lblEmail.Text = objDS("strEmail")

c) If Len(objDS("strEmail")) > 0 Then lblEmail.Text = objDS("strEmail")

thanks,

Nick

******************************************************
Scanned by @lantic IS Virus Control Service
eScan for Windows-based PCs - http://www.escan.co.za
MailScan for SMTP servers - http://www.mailscan.co.za
******************************************************
@lantic Internet Services (Pty) Ltd.
"Virus-FREE Internet!"
http://www.lantic.net



Message #4 by "Nick Charlesworth" <nick@f...> on Wed, 29 May 2002 12:34:51
Thanks a lot, that's solved it.


  Return to Index