sql-server - 为什么我的本地 SQL Express 必须允许远程连接才能使用本地 MDF?
问题描述
当我将我的 VB.net 程序设置为从本地 MDF 数据库文件 (SQL) 中读取时,它告诉我需要远程连接。详情如下:
我有一个 Visual Studiovb.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
解决方案
推荐阅读
- electron - 防止电子应用程序关闭,直到清理完成
- python - 哪个是熊猫的 R which() 的替代品?
- python - 在 Matplotlib 中绘制多个子图时如何去除白线?
- c++ - std::bind c++ in if 语句
- acumatica - 即使在货件状态得到确认、完成或开票后,有人可以帮助我如何在货件屏幕上编辑和保存跟踪号字段
- node.js - Visual Studio Code & nodejs
- r - R:按因子绘制两个单独列的平均值
- mysql - 如何使用表的返回结果访问数据库?
- microsoft-graph-api - 有没有办法使用 IGraphServiceClient 批量删除文件的所有权限?
- python - 正则表达式从字符串中解析产品尺寸(计数、包装尺寸)