我在Visual Studio 2010中开发了一个小项目。在我的项目中,我附加了一个名为database1.mdf
的基于服务的数据库。连接.mdf数据库时出错
我的connectionString是:
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True
它工作正常,在我的电脑开发,但它抛出一个客户端的PC的异常。
的例外是:
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)
我不明白发生了什么。
我也复制我的application.exe和database1.mdf文件在同一个文件夹中。 – Vero009
sqlserver是否在客户机上运行?如果是这样,您尝试更新您的客户端计算机的DataDirectory属性,如AppDomain.CurrentDomain.setData(“DataDirectory”,“C:\ myDB”); – erencan