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
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
5 replies · 3K views
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
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.