我无法使用VB.NET连接到SQL Server Express
问题描述:
有人可以告诉我我在想什么吗?我使用此连接字符串连接到我的数据库,但仍然无法连接:
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:
- 右键单击数据库
- 选择属性,然后单击选择
数据源
我希望我足够清楚。谢谢阅读。
I hope I am clear enough. Thanks for reading.
编辑:
错误消息如下:
无法连接到数据库,请联系管理员
答
最有可能的,您将需要这样的东西:
Most likely, you'll need something like this:
Dim str As String = "Server=.\SQLExpress;AttachDbFilename=C:\Users\konin\Documents\UHMS\bin\Debug\UHMS.mdf;Database=dbname; Trusted_Connection=Yes;"
您仍然需要在计算机上安装SQL Server Express才能加载此*。 mdf文件。
You'll still need to have SQL Server Express installed on your machine in order to load this *.mdf file.