Tim, thanks again for your assistance. I'd be interested to see whether you
think the code below is a good way to handle this issue.

Seamus, here's some code I wrote this morning that deals with the same
issue. It had not occurred to me to use CFFILE until I saw your code, so my
approach was to create a DSN pointing to the text file, then treat it as I
would any other query. I have not compared transaction times, but this
method seems to work quickly. Code follows sig. Obviously you have to create
a DSN pointing to the text file before this code works. Let me know if this
helps.

Regards,

Marc Garrett

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
 <title>test city text driver</title>
 <link rel="stylesheet" href="../Common/common_style.css" type="text/css">
</head>

<body>
<!--- retrieve list of all cities from text file --->
<!--- txt_Cities is the DSN pointing to the text file on the server --->
<cfquery datasource="txt_Cities" name="list_cities">
    SELECT CityCode, City
    FROM Cities.txt
</cfquery>

<!--- show number of records in query and output via loop --->
<p>There are <cfoutput>#list_cities.recordcount#</cfoutput> cities in the
query.</p>
<p>
<cfloop query="list_cities">
 <cfoutput>#CityCode# / #City#</cfoutput><br />
</cfloop>
</p>

<!--- loop through list_cities query and add one record at a time to
tblCityCodes --->
<cfloop query="list_cities">
 <cfset varCityCode = "#CityCode#">
 <cfset varCity = "#City#">
 <!--- BR_RES is the DSN pointing to a SQL Server database that will hold
the new records --->
 <cfquery name="add_city_code" datasource="BR_RES">
  INSERT INTO tblCityCodes(fldCityCode, fldCity)
  VALUES('#varCityCode#', '#varCity#')
 </cfquery>
</cfloop>

<!--- retrieve contents of tblCityCodes after INSERT --->
<cfquery name="show_all_cities" datasource="BR_RES">
SELECT *
FROM tblCityCodes
</cfquery>

<h2>Here are the new contents of tblCityCodes</h2>
<p>
<!--- show new contents of tblCityCodes --->
<cfoutput query="show_all_cities">
#fldAutoNumber#. #fldCityCode# / #fldCity#<br />
</cfoutput>
</p>
</body>
</html>



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to