The example below shows how to connect to a database using the coldfusion cfquery tag. This code is taken from a login validation page that checks the database for the username and password submitted. I\'ve used the cfqueryparam tag to help speed up the validation routing slightly - but I did it more just for good coding habits.
<cfquery name="validateUser" datasource="#application.ds#">
select * from users
where username = <cfqueryparam cfsqltype="cf_sql_varchar" value="#username#">
and password = <cfqueryparam cfsqltype="cf_sql_varchar" value="#password#">
</cfquery>