Link to a MDF database

Tags:
MDF
SQL Server
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

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

If you need to move the database from the default location then just detach and attach the database. Right click on the database and select detach.  Then move the data files (the MDF and the LDF) and then right click the databases node and select Attach.

If you create the database using the CREATE DATABASE statement then you can specify the folder name as part of the CREATE DATABASE statement.

If your connection string has a attach path (or whatever the parameter is to attach the database to the instance) remove that, Just include the server name, database name, username and password. The database is already attached.

Also stop using SQL Server 2000. It’s 17 years old now and there are 6 newer versions of SQL Server.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • morrishall
    If you need to move the database from the default location then just detach and attach the database. Right click on the database and select detach.  Then move the data files (the MDF and the LDF) and then right click the databases node and select Attach.

    If you create the database using the CREATE DATABASE statement then you can specify the folder name as part of the CREATE DATABASE statement.

    If your connection string has a attach path (or whatever the parameter is to attach the database to the instance) remove that, Just include the server name, database name, username and password. The database is already attached.

    Also stop using SQL Server 2000. It's 17 years old now and there are 6 newer versions of SQL Server.
    55 pointsBadges:
    report
  • morrishall

    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.

    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.

    55 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: