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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DSN Problem

Status
Not open for further replies.

lws

Programmer
May 6, 2001
14
HK
Hello,

I want to retrive data from an excel files. However, I don't want to used a fixed DSN in order to retrive data from this excel file. Can anyone give me some tips?
 
dsn can be a variable just like almost anything else in cf, try this:

<cfset dsnName=&quot;nameYouWnatToUseHere&quot;>

<cfquery datasourec=&quot;#dsnName#&quot;...></cfquery>
Sylvano
dsylvano@hotmail.com

&quot;every and each day when I learn something new is a small victory...&quot;
 
Hi Sylvano,

Thx for your reply.
According to your suggestion, do I need to add a data source in Coldfusion Administrator? I don't want to add a data source name manually. I want to generate a data source name from my program so that I can retrive my data by using the DSN that generated before.

 
Try this DSN-less connection. It will be slower than a DSN but should suit your needs

<cfset DBPath=&quot;c:\inetpub\ path and\databasename.mdb&quot;>



<cfquery name=&quot;QueryName&quot;

datasource=&quot;#DBPath#&quot;

dbtype=&quot;OLEDB&quot;

provider=&quot;Microsoft.Jet.OLEDB.4.0&quot;

providerdsn=&quot;#DBPath#&quot; username=&quot;yourusername&quot; password=&quot;yourpassword&quot;

>



SQL statements

</cfquery>
 
if you want to automatize adding database source name to coldfusion administrator, you can use CF_AutoAddMDB; it is a custom tag (unencrypted plain CFML) that will scan a folder and all it's sub-folders, etc looking for MS Access database files (*.mdb). When it finds them it will automatically add a datasource for them using their filename for their datasource name.

you will find that custom tag at:


look for: CF_AutoAddMDB


Sylvano
dsylvano@hotmail.com

&quot;every and each day when I learn something new is a small victory...&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top