Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you use CFCs to wite to database with forms

Status
Not open for further replies.

bluesauceuk

Programmer
Jan 1, 2001
73
0
0
GB
Hello!

I would like to know if I can use CFCs to write to a database, passing the data from a form.

Does anyone know how to do this?

Here's my first cfc - that pulls info from the db
Code:
<CFCOMPONENT>

<CFFUNCTION NAME="ListCategories" 
HINT="ListCategories"
ACCESS="remote"
RETURNTYPE="query">
   
<CFQUERY DATASOURCE="aqua" NAME="category">
   SELECT *
   FROM category
</CFQUERY>

<CFRETURN category>
</CFFUNCTION>

</CFCOMPONENT>

Then the page that calls it!

Code:
<!--- Instantiate component --->
<CFOBJECT COMPONENT="category" NAME="empObj">

<!--- Get departments --->
<CFSET categories=empObj.ListCategories()>
<CFOUTPUT QUERY="categories">
#id#, #description# <br> 
</CFOUTPUT>

Can anyone help?

This works - but I would like to know how to add data. All that's in this table is decription!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top