我无法使用 VB.NET 连接到 SQL Server Express
有人能告诉我我错过了什么吗?我正在使用此连接字符串连接到我的数据库,但仍然无法连接:
Dim str As String = "Provider = .NET Framework Data Provider for SQL Server; Data Source=C:\Users\konin\Documents\UHMS\bin\Debug\UHMS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
这是我用来获取数据源的过程:
- 右键单击数据库
- 选择属性,然后单击选择 数据来源
我希望我足够清楚。感谢您的阅读。
编辑:
错误消息如下:
无法连接到数据库,请联系管理员
Can someone tell me what I am missing? I am using this connection string to connect to my database and still it won't connect:
Dim str As String = "Provider = .NET Framework Data Provider for SQL Server; Data Source=C:\Users\konin\Documents\UHMS\bin\Debug\UHMS.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
This is the process I used to get the data source:
- right-click the database
- select properties and click select
data source
I hope I am clear enough. Thanks for reading.
Edit:
Error Message is as follows:
unable to connect to database please contact administrator
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你能发布错误吗?我从未见过连接到 .mdf 的数据源,仅使用“AttachDbFilename”,您可能想看看 此处了解有关 SQL 连接字符串的详细信息。
Can you post the error? I've never seen the Data Source connected to a .mdf, only with "AttachDbFilename", you might want to take a look here for details on Connection strings for SQL.
最有可能的是,您需要这样的东西:
您仍然需要在计算机上安装 SQL Server Express 才能加载此 *.mdf 文件。
Most likely, you'll need something like this:
You'll still need to have SQL Server Express installed on your machine in order to load this *.mdf file.
假设您的应用程序是一个 Web 应用程序...您需要将基于文件的数据库放置在项目的 App_Data 文件夹中才能正常工作。我注意到位于 Debug 文件夹中...
Assuming yours is a web application... you need to place your file based database in the App_Data folder of your project for it to work. I noticed is located in the Debug folder...