2011-07-06 53 views
3

我有Visual Studio 2008和Installed MVC2 RTM。 对于数据的基础上我了SQL Server 2008从注册页面创建用户时,asp.net mvc无法连接到SqlServer

当我第一次创建类型“asp.net MVC Web应用程序” 的一个项目,我拿到项目和app_data文件的默认结构。 当我运行该项目并尝试注册一个新用户它给出了以下错误。

The user instance login flag is not supported on this version of SQL Server. The connection will be closed. 

显示上述消息,而连接字符串值是

<connectionStrings> 
    <add name="ApplicationServices" connectionString="data source=.;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/> 
</connectionStrings> 

我发现了下面的错误时数据源= \ SQLEXPRESS

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) 

任何想法,为什么它没有连接到数据库?

在此先感谢。

+0

http://stackoverflow.com/questions/3277866/asp-net-website-administration-tool-unable-to-connect-to-sql-server-database你可以找到解决方案在这里。 –

回答

1

它看起来像你正在使用一个完整的SQL Server。

总部设在Anand Kumar M的评论的链接,当您使用的是完整的SQL服务器不能使用AttachDBFilename,所以尽量去除您的连接字符串和数据库附加到SQL服务器上

用于将数据库附加到SQL Server实例。
http://msdn.microsoft.com/en-us/library/ms190209.aspx

一旦你做到了这一点,从您的ConnectionString去除AttachDbFilename条款,并替换为以下:

Initial Catalog=Mydatabase; 

哪里MyDatabase是数据库的名称,因为它显示了在SSMS。

希望这有助于