EscapeBit Function:
Escapes a boolean field for sql statements (sql server).
Description:
Escapes a boolean into an input useful for entering into a bit field for sql server statements. If the input is null or zero length, EscapeBit will return "null" otherwise it will return a 0 or 1. A 0 is returned if the input = 0 or cbool(input) returns false. Otherwise a 1 is returned to indicate true.
Syntax:
escapedString = EscapeBit(True)
Example:
<%
dim bUnknown, sql
bUnknown = true
sql = "select * from table where bit_field = " & escapebit(bUnknown)
%>
ASP Source Code:
<%
function escapebit(byval sInput) if isnull(sInput) then escapebit = 0 exit function end if if len(trim(sInput)) = 0 then escapebit = 0 exit function end if if sInput = 1 then escapebit = 1 exit function end if if sInput = 0 then escapebit = 0 exit function end if if not cbool(sInput) then escapebit = 0 exit function end if escapebit = 1 end function
%>
|