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

In summary, you need a web server and a database server to create a web application. 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.
  • #1
BjornPorgilsson
3
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 morrishall
Technology news on Phys.org
  • #2
Guys, can help me? I would be grateful for any advice.
 
  • #3
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 BjornPorgilsson
  • #4
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 BjornPorgilsson
  • #5
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 BjornPorgilsson
  • #6
Thank you all for your advice! I'm appreciative for your responses and help.
 

1. What is an MDF database?

An MDF database is a file extension used by Microsoft SQL Server to store and manage data. It stands for "Master Database File" and contains the primary data for the database.

2. How do I link to an MDF database?

The most common way to link to an MDF database is by using Microsoft SQL Server Management Studio, which allows you to connect to the database and perform various tasks such as querying, editing, and managing the data.

3. Can I link to an MDF database from a different program?

Yes, as long as the program supports connections to SQL Server databases, you can link to an MDF database. This can be done through an ODBC or OLE DB connection.

4. Do I need special permissions to link to an MDF database?

In order to link to an MDF database, you will need to have sufficient permissions on the server where the database is located. This may include permissions to access the server, the database, and the specific tables or data within the database.

5. How do I troubleshoot issues with linking to an MDF database?

The first step in troubleshooting linking issues is to ensure that the database is accessible and that you have the correct permissions. You may also need to check for any network or firewall issues that could be preventing the connection. If all else fails, you can seek assistance from a database administrator or IT professional.

Similar threads

  • Programming and Computer Science
2
Replies
50
Views
4K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
Replies
11
Views
1K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
1
Views
2K
  • Computing and Technology
Replies
24
Views
7K
  • Programming and Computer Science
Replies
13
Views
2K
Replies
5
Views
948
Back
Top