ASP 101 - Active Server Pages 101 - Web04
The Place ASP Developers Go!

Please visit our partners

Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates














ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash


 Top ASP 101 Stories Top ASP 101 Stories
An Overview of ASP.NET
Connections, Commands, And Procedures
What is ASP?

QUICK TIP:
Scope out your variables
Show All Tips >>


ASP Source Code:
<%
'------------------------------------------------------------------------------
Function SQLPrep_s(ByVal StringValue, ByRef MaxLength)
	If MaxLength > 0 Then
		StringValue = Left(StringValue, MaxLength)
	End If
	StringValue = Replace(StringValue, "'", "''")
	If StringValue = "" Then
		SQLPrep_s = "NULL"
	Else
		SQLPrep_s = "'" & StringValue & "'"
	End If
End Function
'------------------------------------------------------------------------------
Function SQLPrep_n(ByVal NumericValue)
	If IsNumeric(NumericValue) And NumericValue <> "" Then
		SQLPrep_n = NumericValue
	Else
		SQLPrep_n = "NULL"
	End If
End Function
'------------------------------------------------------------------------------
Function SQLPrep_b(ByVal BooleanValue, ByRef DefaultValue)
	Const DB_TRUE = 1	'1 = SQL, -1 = Access
	Const DB_FALSE = 0
	Dim lbResults
	On Error Resume Next
	If BooleanValue = "" Then BooleanValue = DefaultValue
	lbResults = Cbool(BooleanValue)
	If Err Then
		Err.Clear
		lbResults = DefaultValue
	End If
	If lbResults Then
		SQLPrep_b = DB_TRUE
	Else
		SQLPrep_b = DB_FALSE
	End If
End Function
'------------------------------------------------------------------------------
Function SQLPrep_d(ByVal DateValue)
	If IsDate(DateValue) Then
		SQLPrep_d = "'" & DateValue & "'"
	Else
		SQLPrep_d = "NULL"
	End If
End Function
'------------------------------------------------------------------------------
Function SQLPrep_c(ByVal CurrencyValue)
	On Error Resume Next
	If CurrencyValue = "" Then
		CurrencyValue = "NULL"
	Else
		CurrencyValue = CCur(CurrencyValue)
		If Err Then
			Err.Clear
			CurrencyValue = "NULL"
		End If
	End If
	SQLPrep_c = CurrencyValue
End Function
'------------------------------------------------------------------------------
%>


Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback

Solutions


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers