Hi,
Im new to CFC (coldfusion components), one thing I noticed is that it doesn't read my application.cfm.
So in my cfc file, i still have to set my datasourcename.
Normally Im used to set my DSN in one application file(application.cfm) so I dont have to set DSN on other pages or files..
Please help me on this, I wanted my cfc file as dynamic as possible and dont have to hardcode all over again my DSN.
Please see code below, notice that I have to re-set my DSN on my application.
Many thanks in advance.
Im new to CFC (coldfusion components), one thing I noticed is that it doesn't read my application.cfm.
So in my cfc file, i still have to set my datasourcename.
Normally Im used to set my DSN in one application file(application.cfm) so I dont have to set DSN on other pages or files..
Please help me on this, I wanted my cfc file as dynamic as possible and dont have to hardcode all over again my DSN.
Please see code below, notice that I have to re-set my DSN on my application.
Many thanks in advance.
Code:
<cfcomponent>
[b]<cfset DSN = "msmdevTestDB">[/b]
<cffunction name="addEmp" displayname="Add Employee" returntype="any">
<cfargument name="first_name" type="string" required="yes" default="#form.first_name#">
<cfargument name="last_name" type="any" required="yes" default="#form.lastname#" >
<cfargument name="address" type="variablename" required="yes" default="#form.addressnew#">
<cfquery name="addRecordEmp" datasource="[b]#DSN#[/b]">
insert into EMPLOYEE (first_name,last_name,address)
values('#arguments.first_name#','#arguments.last_name#','#arguments.address#')
</cfquery>
<cfreturn true>
</cffunction>
</cfcomponent>