Under Construction!

Click for Home

Textarea tag problems...

The textarea tag puts a carriage return <CR> in at the end of your text by default.  This can cause a problem in your code later on.  To solve this, use the StripCR("#variable.txt#") function to remove the carriage returns from your variable.

The Evaluate function...

Let's say I had a form on one page which had a text box defined as follows: <input type=text size=10 name="Text#variable_name#">  where the #variable_name#  is defined by an SQL statement.  Now, in the following page, how are you going to use that field if you don't know the name of it?  The answer is the Evaluate() function.

what you would do in this case is runt he same SQL statement on the next page and create a variable as follows:  <cfset myvar= Evaluate("Text#variable_name#")> and this will set the myvar variable to the same value of the text input box.

Appending variables...

A variable can have data appended to it by using the following example:

<cfset foo = foo & "This is a test">

This will add "This is a test" after whatever foo is set to.

Outputting html tags...

If you have a variable with HTML tags in it, which you do not want to have processed, then use the <XMP> tags around the data, you want to output and any HTML tags within will not be processed.

Using text files...

In my application, I had original stored the call details in the SQL server, but then I ran into problems if the data was over 255 characters and the logs themselves were starting to be quite large.  To solve this, I put all the descriptions in a text file, which I can then call in using the CFFILE tag.  This tag is useful when creating log files or storing anything that needs allot of space and may expand.

Excel Statements...

The following is an example of how to do SQL statements with Excel 5.0 files:

<cfquery name="aquery" datasource="excel">
Select Addressone, Addresstwo, Addressthree, Addressfour, City, County, Postcode, Phoneno, Mobile, Faxno, Extra, Type from `i:\stats.xls`.`Ownership$`
</cfquery>

<cfquery name="aquery" datasource="excel">
Insert into `i:\stats.xls`.`Ownership$` (Ownership,received,Outstanding,Resolved)
values ('#cn#','#totalcalls#','#outstandingcalls#','#resolvedcalls#')
</cfquery>

These statements select and insert into the i:\sats.xls workbook file and on the Ownership page of the workbook.


UPDATE...

There has been many questions about the Excel driver and SQL statements.  Here's how I make it work:

I use the Microsoft Excel 3.51.102900 ODBC Driver.  All the latest drivers are installed
when you install the Microsoft Data Access components.  Best of all it's free!  you can
find it at:  http://www.microsoft.com/data/download.htm  and it has all the latest SQL
drivers as well.

My Excel SQl works fine.  I use it to output all my stats.  The trick I use is to set up the
workbook with all the pages set up (has all the column names and the rest blank) and
save it as Excel version 5.0.  Next I use CFFILE to delete any existing file by the same
name in another directory and then copy the "template" file over.  Then I use the SQL
statement that you see above to access the file and everything works fine.  I do
have to open the file and run a micro that converts the text to columns (This makes the data actually usable to run formulas on) and save it under another name, but then I mail it out via an automatic email.

The whole thing works really sweet.

I do understand though that here is many questions about what statements actually work.  I guess I only know what I have tried works, so I can not help you there.  If you look in the forums, there is allot of discussion about what works or doesn't.

Here is a Microsoft Knowledge Base article that explains the limitation with the 3.x excel driver regarding writes and updates to an excel spreadsheet (Thanks V. Delgado.):

  http://support.microsoft.com/support/kb/articles/q178/7/17.asp

Too bad that's all the info I can give you for now.


   Continue to Next Page                                                  Previous Page

This page hosted by Get your own Free Homepage