What I am trying to do is login from a form and have the user name from that form then be passed as a variable to my next application.cfc to be used to name my application.datasource.
If this can be done with one cfc file that would be great, but just figuring it out would be great too.
The reason I have cfset application.datasource listed twice, in the scond code block, is because I have another section of the site that usese cfset application.datasource, and I could not get one to clear when moving from one section of the site to the next, so I was trying to get that cfc to load an new application.datasource everytime
Application.cfc code
CODE
<cfcomponent>
<cflogin>
<cfif isdefined("form.userName")>
<cfquery datasource="mysqlcf_dtcrm" name="[b]quser[/b]">
select *
from users
Where userName = '#form.userName#' AND
Password = '#form.password#'
</cfquery>
<cfif quser.recordcount IS 1>
<cfloginuser name="#quser.userName#"
password="#quser.password#"
roles="#quser.userrole#">
<cfelse>
<cfinclude template="Login/loginform.cfm">
<cfabort>
</cfif>
<cfelse>
<cfinclude template="Login/loginform.cfm">
<cfabort>
</cfif>
</cflogin>
</cfcomponent>
users/application.cfc code
CODE
<cfcomponent>
<cfquery name="quserByUserID" datasource="mysqlcf_dtcrm">
SELECT *
FROM users
WHERE userName = <cfqueryparam value="#[b]quser.userName[/b]#">
</cfquery>
<cffunction name="onRequestStart" access="public" returntype="void">
<cfargument name="thisRequest" required="true"/>
<cfif IsDefined("application.datasource")>
<cfoutput>
<cfset application.datasource="jstickel73_accesscf_#quserByUserID.userName#">
</cfoutput>
</cfif>
<cfif NOT IsDefined("application.datasource")>
<cfoutput>
<cfset application.datasource="jstickel73_accesscf_#quserByUserID.userName#">
</cfoutput>
</cfif>
</cffunction>
</cfcomponent>