连接到 .MDF 的连接字符串

发布于 2024-07-22 04:11:49 字数 168 浏览 5 评论 0原文

我在VS2008中创建了一个新项目,并向该项目添加了一个.MDF文件。 这是我第一次尝试使用 MDF 文件和 .SQLEXPRESS 数据库(过去我一直使用外部 Oracle 服务器)。

我正在尝试记录所有内容,但我无法弄清楚使用哪些凭据来连接到 .MDF 文件。 有没有简单的方法可以找出来?

I've created a new project in VS2008, and added a .MDF file to the project. This is the first time I've tried to use the MDF files and .SQLEXPRESS databases (I've always used extenal Oracle servers in the past).

I'm trying to document everything as I go, but I can't figure out what credentials are being used to connect to the .MDF file. Is there an easy way to find out?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你穿错了嫁妆 2024-07-29 04:11:49

如果您使用 ASP.NET 应用程序的 App_Data 文件夹中的 *.mdf 文件,则可以使用此文件。

服务器=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;数据库=dbname; Trusted_Connection=是;

如果它不是 ASP.NET 应用程序,请不要使用 DataDirectory 语法,而仅使用完整的 c:\... 路径。

If you're using the *.mdf file in the App_Data folder of an ASP.NET app you can use this.

Server=.\SQLExpress;AttachDbFilename=|DataDirectory|mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;

If it's not an ASP.NET application don't use the DataDirectory syntax and just use the full c:\... path.

就像说晚安 2024-07-29 04:11:49

mydbfile 这个名字来自哪里?

如果您使用 ASP.NET 应用程序的 App_Data 文件夹中的 *.mdf 文件,则可以使用此文件。

Server=.\SQLExpress;AttachDbFilename=|DataDirectory|**mydbfile**.mdf;Database=dbname; Trusted_Connection=Yes;

如果它不是 ASP.NET 应用程序,请不要使用 DataDirectory 语法,而仅使用完整的 c:... 路径。

from where this name mydbfile ?

If you're using the *.mdf file in the App_Data folder of an ASP.NET app you can use this.

Server=.\SQLExpress;AttachDbFilename=|DataDirectory|**mydbfile**.mdf;Database=dbname; Trusted_Connection=Yes;

If it's not an ASP.NET application don't use the DataDirectory syntax and just use the full c:... path.

咆哮 2024-07-29 04:11:49

对于本地数据库且没有 SQLEXPRESS 服务器:

"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=""|DataDirectory|\MyDB.mdf"";Integrated Security=True;Connect Timeout=30"

For a local DB and no SQLEXPRESS server:

"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=""|DataDirectory|\MyDB.mdf"";Integrated Security=True;Connect Timeout=30"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文