当我设置VB.net程序以从本地MDF数据库文件(SQL)读取时,它告诉我需要远程连接。详细信息如下:
我有一个Visual Studio vb.net
应用程序。它需要一个数据库,所以我下载了SQL Express并运行了一个脚本来添加我的数据库。这很好。然后,我想将程序发送给同事,我想应该将数据库MDF和LDF文件复制到程序的App_Data文件夹中,然后使用可以读取MDF的连接字符串。
连接字符串似乎正常:
Server=.\SQLExpress;AttachDbFilename=C:\gideonwroteprograms\EchoTheory\Echo
Theory\bin\Debug\App_Data\EchoDatabase.mdf;Database=EchoDatabase;Trusted_Co
nnection=Yes;
但是我收到一条消息,说我现在需要允许远程连接(我认为这是安全隐患)。
消息是:
System.Data.SqlClient.SqlException
HResult=0x80131904
Message=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)
Source=.Net SqlClient Data Provider