Generally we can add a local MDF file through the SQL explorer of VS2005. Maybe you may have the following problem:
Exception Details: System.Data.SqlClient.SqlException: The user instance login flag is not supported on this version of SQL Server. The connection will be closed.
Search by. We found that the information we need is here: Error Message: The user instance login flag is not supported on this version of SQL Server. The connection will be closed.
Carefully analyze Scott's answer:
"The issue is that User Instancing, which allows the automatic creation of databases from code, isn't support on the full version of SQL 2005. That is a function of SQL Express only. The solution is to manually create the database in SQL Server 2005 and set a connection string to point to it. You will also need to run aspnet_regsql.exe manually against the database if you will be using any of the new built-in database features of ASP.NET v2.0."
Therefore, if we are not using SQL Server 2005 downloaded from MS Express, then we can only connect it by adding the MDF file in the SQL2005 manager.
Solution: On the SQL2005 manager, after successfully attaching the local MDF file. Just connect to the sql explorer of VS2005.
Will continue to add later.
cnzc's blogs