Can I Create and Link to an MDF Database in a Specific Folder for ColdFusion?

  • Thread starter Thread starter BjornPorgilsson
  • Start date Start date
  • Tags Tags
    Database Link
Click For Summary

Discussion Overview

The discussion revolves around the challenges of creating and linking a Microsoft SQL Server database (MDF file) in a specific folder (C:/Cfusion/wwroot) for use with ColdFusion. Participants explore the implications of database file locations, connection methods, and configurations necessary for integration with web applications.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Conceptual clarification

Main Points Raised

  • One participant expresses a desire to create a database in the C:/Cfusion/wwroot folder instead of the default ProgramFiles/Microsoft SQL/Data folder, questioning the feasibility of this setup.
  • Another participant clarifies that SQL Server does not connect directly to the MDF file but to the server, emphasizing the need to create a database through SQL Server Management tools.
  • A suggestion is made to avoid placing MDF and LDF files in the web document tree for security reasons, recommending a separate folder under "Inetpub" for SQL data files.
  • There is a mention of the process required to move a data file, which involves detaching the database, moving the file, and reattaching it.
  • One participant advises using native SQL Server drivers with ColdFusion instead of ODBC, detailing the necessary configuration steps for setting up a datasource.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best approach to link the MDF file for ColdFusion, with differing views on file location, connection methods, and security practices remaining evident throughout the discussion.

Contextual Notes

Participants express uncertainty regarding the implications of file locations on database accessibility and security, as well as the specific steps required to configure ColdFusion with SQL Server. There are references to SQL Server documentation for further guidance, but no definitive solutions are agreed upon.

BjornPorgilsson
Messages
3
Reaction score
1
So I created a MS SQL db , but now I cannot link to it.

I WOULD like to create a database in my C:/Cfusion/wwroot folder and not in ProgramFiles/MicsoSQL/Data folder.

Is that possible? How? I cannot create a new database in anywhere but ProgramFiles/MicsoSQL/Data folder.

Now I have an mdf in wwroot, but it does not show in enterprise manager?

This is bothering me because I need to select it so I can create a super user for it , and then an ODBC datasource so I can use it with coldfusion.

I think it needs to be in my wwwroot to work for coldfusion
 
  • Like
Likes   Reactions: morrishall
Technology news on Phys.org
Guys, can help me? I would be grateful for any advice.
 
BjornPorgilsson said:
So I created a MS SQL db , but now I cannot link to it.

I WOULD like to create a database in my C:/Cfusion/wwroot folder and not in ProgramFiles/MicsoSQL/Data folder.

Is that possible? How? I cannot create a new database in anywhere but ProgramFiles/MicsoSQL/Data folder.

Now I have an mdf in wwroot, but it does not show in enterprise manager?

This is bothering me because I need to select it so I can create a super user for it , and then an ODBC datasource so I can use it with coldfusion.

I think it needs to be in my wwwroot to work for coldfusion

When you create a web application you must have a web server and a database server. You put your web pages - or parts of the web application that are used / served by the web server in general, in the root folder of your web server (following some tree structure) and you create connections to the database server, in order to request content. Now, in order to work with ColdFusion and IIS (and any other web server for that matter), ColdFusion server takes the SQL content of the cfquery tag and passes it to the specified driver of the data source. So, you have to configure data source first. For how to do this take a look here. The data files for the database server are kept in the database server.

Also, if you want to take a look at some basics of ColdFusion - in case you don't know ColdFusion (although not very popular any more) here is an interesting link.
 
  • Like
Likes   Reactions: BjornPorgilsson
SQL Server does not behave the same way as Access. You do not connect to the MDF file. You connect to the server and select a database. The default location for the database files is (I think),

\Program Files\Microsoft SQL Server\MSSQL\Data,

though you can point a database to a different location when you create the database (either with Query Analyzer (QA) or Enterprise Manager (EM)).

Please look at "CREATE DATABASE" in the books online. If you are creating the database in EM, look at the "Location" box in the "Data Files" or "Transaction Log" tabs of the "Database Properties" box. I would highly recommend that you not put the mdf and ldf files anywhere in your web document tree. They should not be accessible from any URL. You might want to create a folder called "Data" under "Inetpub" for the SQL data files that is not world-readable.
 
  • Like
Likes   Reactions: BjornPorgilsson
If you wish to move a data file, then you need to detach the database, move the data file, and reattach the db (see "sp_detach_db" in Books Online). If the file is corrupted or doesn't open you, then you need mdf opener.

As for ColdFusion, it comes with native SQL Server drivers that you should use instead of ODBC. On the datasources page, enter a name for your datasource (this can be anything, it's just a description to use in your CFQUERY's) and select Microsoft SQL Server as the type. Then, the database name is the name of your database in SQL Server, the server is the hostname or IP address running SQL Server (i.e. localhost) and the username and password are a SQL Server user name. Your SQL Server should be set for mixed-mode, and you should have created the user in EM with access to the database.
 
  • Like
Likes   Reactions: BjornPorgilsson
Thank you all for your advice! I'm appreciative for your responses and help.
 

Similar threads

  • · Replies 50 ·
2
Replies
50
Views
9K
Replies
5
Views
3K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
2
Views
3K
  • · Replies 24 ·
Replies
24
Views
11K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
4
Views
5K