******
THE CFC CODE (maint.cfc)
******

<cfcomponent>
<cffunction name="insertHostingProvider" access="public" returntype="struct"
output="false" displayname="Insert A Hosting Provider" hint="Takes form data
and inserts it into a Hosting Provider Table. Returns ID of inserted record
in a struct.">
<cfargument name="InsertContents" required="true" type="struct"
displayname="Insert Contents" hint="A Struct containing all the content from
the form, to be inserted with the CFC">
  <cfset var ret = structNew()>
  <cfset ret.error = "">
  <cfset ret.id = 0>

<cftry>
  <cfquery name="insertHostingProvider"
datasource="HardCodedDataSourceName">
  SET NOCOUNT ON

  INSERT INTO tblHostingProvider (Name, Address, City,"State", Zip, Phone,
Fax, Website, ContactFirstName, ContactLastName)
  VALUES (<cfqueryparam value="#arguments.InsertContents.Name#"
cfsqltype="CF_SQL_CHAR">,
    <cfqueryparam value="#arguments.InsertContents.Address#"
cfsqltype="CF_SQL_CHAR">,
    <cfqueryparam value="#arguments.InsertContents.City#"
cfsqltype="CF_SQL_CHAR">,
    <cfqueryparam value="#arguments.InsertContents.State#"
cfsqltype="CF_SQL_CHAR">,
    <cfqueryparam value="#arguments.InsertContents.Zip#"
cfsqltype="CF_SQL_CHAR">,
    <cfqueryparam value="#arguments.InsertContents.Phone#"
cfsqltype="CF_SQL_CHAR">,
    <cfqueryparam value="#arguments.InsertContents.Fax#"
cfsqltype="CF_SQL_CHAR">,
    <cfqueryparam value="#arguments.InsertContents.Website#"
cfsqltype="CF_SQL_CHAR">,
    <cfqueryparam value="#arguments.InsertContents.ContactFirstName#"
cfsqltype="CF_SQL_CHAR">,
    <cfqueryparam value="#arguments.InsertContents.ContactLastName#"
cfsqltype="CF_SQL_CHAR">)

  Set NOCOUNT OFF
  SELECT ID=@@IDENTITY
  </cfquery>

  <cfset ret.id = insertHostingProvider.ID>
<cfcatch type="Database">
  <cfset ret.error = "Could not preform insert of a new Hosting Provider -
DB problem">
  <cfreturn ret>
</cfcatch>
</cftry>

<cfreturn ret>
</cffunction>

</cfcomponent>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to