How to use cfsqltype in cfqueryparam tag in ColdFusion

CFqueryparam and CFsqltype

Usingcfsqltype.cfm


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>cfqueryparam and cfsqltype - how to use cfsqltype in cfqueryparam tag</title>
</head>

<body>
<h2 style="color:DarkBlue; font-style:italic">ColdFusion cfqueryparam tag example: how to use cfsqltype</h2>
<hr width="600" align="left" color="PowderBlue" />
<br />


<cfparam name="url.EmpID" default="0">

<cfquery name="qEmploees" datasource="cfdocexamples">
 select Emp_ID, FirstName, LastName from Employee
    where Emp_ID = <cfqueryparam value="#url.EmpID#" cfsqltype="cf_sql_integer">
</cfquery>

<div style=" font-family:'Lucida Sans Unicode', 'Lucida Grande', sans-serif; font-size:large;">
    <a href="Usingcfsqltype.cfm?EmpID=1">Employee ID = 1</a> <br />
    <a href="Usingcfsqltype.cfm?EmpID=2">Employee ID = 2</a> <br />
    <a href="Usingcfsqltype.cfm?EmpID=3">Employee ID = 3</a> <br />
</div>
<br />

<table border="0" cellpadding="2" cellspacing="2" bgcolor="OrangeRed" width="350">
 <tr style="background-color:DeepPink; color:Snow; font-weight:bold;">
     <td>
   Employee ID        
        </td>
     <td>
         First Name
        </td>
     <td>
         Last Name
        </td>
    </tr>
 <cfoutput query="qEmploees">
        <tr style="color:Snow; background-color:HotPink; font-family:'Courier New', Courier, monospace;">
            <td>
                #EmpID#        
            </td>
            <td>
                #FirstName#
            </td>
            <td>
                #LastName#
            </td>
        </tr>
    </cfoutput>
</table>

</body>
</html>












More ColdFusion tutorials