WelcomeServicesPortfolioKnowledge BaseContact Us
27 Seconds, Inc.


Knowledge base View Article

need hosting?

Need hosting? We use and love our host - CrystalTech.com!
Need hosting? We use and love our host - CrystalTech.com!

Text Disguise - CAPTCHA-image/Human Interactive Proof web services

National Holiday Dates and Bank Holiday Dates - web site that provides the dates of national and bank holidays for the United States, United Kingdom, Ireland and Scotland

Holiday Web Service - web services for programmers to provide the dates of national and bank holidays in their applications for the United States, United Kingdom, Ireland and Scotland

Our Family Heart - web site to help families communicate no matter where they are

What?! You haven't heard about the greatest remote controlled flyer to come out in years?! Checkout the FlyTech DragonFly now!

Handle NULL values when updating using RS object.

Summary: When you store data into a database, you want to store NULL instead of a blank field.
 
Keywords: ADDNEW
OBJECT
RECORDSET
SQL
UPDATE
Applicable Software: Active Server Pages (ASP)
Microsoft Access
Microsoft SQL Server
 
Body:

This function handles the conversion for you when you are using a recordset object for the updates.

Function SQLRecordSetFieldValue(fieldValue)
Dim m_sOut
	If Len(Trim(fieldValue)) > 0 Then
		m_sOut = Trim(fieldValue)
	Else
		m_sOut = Null
	End If

	SQLRecordSetFieldValue = m_sOut
End Function

So, to use it, you would just open up a recordset object (assuming you have opened a database connection):

'adOpenKeySet = 1
'adLockOptimistic = 3
'adCmdTable = 2
oRS.Open "tblArticles", oConn, 1, 3, 2
    oRS.Fields("ATitle").Value = SQLRecordSetFieldValue(Request.Form("ATitle"))
    oRS.Update
oRS.Close

 
Author: Douglas L. Setzer, II, http://www.27seconds.com
Posted On: 3/5/2002 11:37:21 AM

Rate this article: Average: 5.5
n/a12345678910
Comments?

Article Search   |   All Articles

 

 
©2002 27 Seconds, Inc. All Rights Reserved.