连接到.MDF的连接字符串 [英] Connection String to Connect to .MDF

查看:184
本文介绍了连接到.MDF的连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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).

我正在尝试记录所有内容,但是我无法弄清楚正在使用什么凭据来连接到.MDF文件.有一种简单的方法可以找到答案吗?

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?

推荐答案

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

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 =是;

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

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

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

这篇关于连接到.MDF的连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆