Link to home
Start Free TrialLog in
Avatar of McHack
McHack

asked on

Data source connection without ColdFusion Administrator

Does anyone know if it is possible to connect to a data source without using ColdFusion Administrator?

If it is possible can anyone show an example connection to an Access database and one to an Excel spreadsheet?
Avatar of anandkp
anandkp
Flag of India image

hi this is easy

<cfset DBPath="D:\InetPub\wwwRoot\YourSite\file.mdb">

<cfquery name="QueryName"
datasource="#DBPath#"
dbtype="OLEDB"
provider="Microsoft.Jet.OLEDB.4.0"
providerdsn="#DBPath#"
username="Admin"
password="">

..Your SQL statments...

</cfquery>

OR

<cfquery
name="selectData"
connectstring="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=[user];pwd=[pass];Initial Catalog=[Database Name];Data Source=[Server Name]"
dbtype="dynamic">
select username from users
</cfquery>

K'Rgds
Anand
Avatar of McHack
McHack

ASKER

anandkp

Thanks for the input.

Will this work if the data source is on a remote server?

In other words will I have to be able to set up an ODBC connection or will the code you posted handle the entire connection process even if the data source is on a remote server?
ASKER CERTIFIED SOLUTION
Avatar of anandkp
anandkp
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The problem is that doesn't work with CFMX, if you use cfmx you can have some troubles finding a solution, the only solution to that problem ( if using cfmx ) is to conect thru ADO, wich is very painfull and only works in the win platform ...

regards,
idss
Avatar of McHack

ASKER

Thanks  anandkp

I think this should work.