Using AttachDBFilename option for MSSQL |
Article ID: 352 |
Back to Search
|
Problem:
If your ASP/ASP.net application on our hosting servers uses the AttachDBFile option for connecting to a MSSQL Express *.mdf database file, you'll run into connection errors like this:
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
The following is an example of the type of connection string we're describing:
<connectionStrings>
<add name="TestVB1.Settings.Database1ConnectionString"
connectionString="Data Source=.\SQLEXPRESS;
AttachDbFilename=|DataDirectory|\Database1.mdf;
Integrated Security=True;
User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
The AttachDBFile option is designed for environments where the MSSQL instance resides on the same machine, and is designed for testing/development, not production environments. It's designed to ease test/development environments by allowing you to attach the db to the local MSSQL instance without creating the db within the MSSQL instance prior. 3Essentials hosts MSSQL database on a seperate MSSQL server to provide optimal performance and manageability. The AttachDBFilename option does not work in this type of environment.
Solution:
The solution is simple, you simply need to create your database on our MSSQL hosted server, populate your database with your data, and modify your connection string to point to the new location. Here's some additional help for you with those steps.
- Create the database on our hosted server... log into your control panel, click on the domain, click on DB (databases), click on ADD A DATABASE. Once you've created the database, be sure to ADD A DB USER ... you'll need at least 1 db user/pw to use in your code to connect to the database.
- Populate your database...
- if you have a database already on your system and you want to get that data into the db you just created on our servers, see the following KB article: How do I get my MSSQL database onto 3Essentials MSSQL database servers?
- If you just created a new db, and want to start populating it from scratch (i.e., you don't have another db to restore to it), then use the DBWebAdmin link in the control panel available right after you created the database.
- Modify your connection string to point to the new location. Your connection string will contain the Data Source (the hostname of the database server), the database name, the db user/pw to connect with, both of which you just created when you added the db. The hostname of the DB server will depend on which server we have your website hosted on:
- If you're hosted on web8, 10, or 12, your db server is: mssql8.3essentials.com
- If you're hosted on web14 or 16, your db server is: db1.3essentials.com
|
|
Downloads Associated With This Article |
No downloads are currently associated with this article. |