dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 6, 1997

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Null Handling in Database I/O

Nulls are still a problem in VB3/VB4-they cause unexpected errors. To handle them, you can read the MDB field into a variant, which can hold a null and then test for it later, or replace all nulls with blank strings to protect the application. To me, nulls serve no logical purpose. I prefer to eradicate them immediately. I have developed a family of I/O pick-up routines that I use at the physical interface next to the database field:
 
Public MyDB As Database
Public MyRS As Recordset
Dim TestVariant As Variant
Set MyDB = OpenDatabase("testjet3db")
Set MyRS = MyDB.OpenRecordset("NameTable")
'Sample Calls
TestVariant = ScreenForNull(MyRS![FirstName])
TestVariant = ScreenForNull(MyRS![FirstName], " ")
Public Function ScreenForNull(aField As Variant, Optional _
	ByVal DefaultReturn As Variant) As Variant
	If IsNull(aField) Then
		If Not _
			IsMissing(DefaultReturn) Then
			ScreenForNull = DefaultReturn
		Else
			ScreenForNull = ""
		End If
	Else
		ScreenForNull = aField
	End If
End Function
Stan Mlynek
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date