Asp.net|server|sqlserver
Since I only installed SQLSERVER2005 on my machine, instead of installing SQL Server EXPRESS, I deployed the user Profile encountered Aspnetdb.mdf can not connect the problem, after a toss, finally solved, the following experience to write down to share with you.
Because there is no aspnetdb.mdf database, you have to create one, which can be done through Aspnet_regsql.exe, which is located under C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\.
Press the "Next >" button
we find that in addition to the configuration database, there is also the ability to delete the database, in the future may be useful, now naturally selected Configure SQL Server for application services, press the "Next >" button
Now go to the database selection interface, and if SQL Server is installed locally, you can simply press "Next >" without changing anything. The database shown here is <default>, which means the default is ASPNETDB, and you can change the name to suit your needs.
now press "Next >" can start to install the database, when the Finish button is lit, indicating the success of the database installation, everything goes well!
The next step is to set the database connection string.
By default, the LocalSqlServer property in Web.config is configured like this:
<connectionStrings>
<add name= "LocalSqlServer" connectionstring= "Data source=./sqlexpress;integrated security=true; attachdbfilename=| Datadirectory|aspnetdb.mdf; User Instance=true "
Providername= "System.Data.SqlClient"/>
</connectionStrings>
This connection string is specially prepared for SQL Server Express, and the following error occurs if SQL Server Express is not installed
An error has occurred while establishing a connection to the server. When connecting to SQL Server in failure, this is 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)
This indicates that the connection could not be established at all. To this end, I tried to change DataSource to./local SQL Server instance name, resulting in an error:
Login Failed for User machinename\aspnet
Again, try to set the user instance to false and error again:
Invalid value for key ' AttachDbFileName '.
In fact, the reason for the error is very simple, because the App_Data directory does not aspnetdb.mdf this file. Checked on the Internet, finally found the solution, reset the connection string to
<add name= "LocalSqlServer" connectionstring= "Data source=[instance name];initial catalog=aspnetdb;integrated Security=false; Uid=sa; Pwd=xxxxxx "
is actually standard SQL Server connection string, depressed ...