Visual Studion 2008 App_Data 默认值

发布于 2024-08-06 11:43:25 字数 257 浏览 4 评论 0原文

是否可以将 App_Data 文件夹与 SQL Server 2005 结合使用?

当我尝试时,它指定了 Express,即使我已将“工具”>“选项”>“数据库”>“数据连接”更改为正确的服务器。我已在本地下载了 SQLEXPR32_x86_ENU.exe 版本 10.0.1600.22 文件,并进行了 7 次安装和卸载,但出现了各种不同的错误。我几乎放弃了 Express,并希望找到一种解决方法(如果存在)。

谢谢

丹尼斯·基思

Is it possible to use the App_Data folder in conjunction with SQL Server 2005?

When I try it specifies Express even though I have changed the Tools>Options>Database>Data Connections to the correct server. I have downloaded SQLEXPR32_x86_ENU.exe Version 10.0.1600.22 file locally and have gone through 7 installs and deinstalls with a variety of different errors. I pretty much given up on Express and would like to find a workaround if it exists.

Thanks

Dennis Keith

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

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

发布评论

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

评论(2

定格我的天空 2024-08-13 11:43:25

将 *.mdf 文件放入 App_Data 并将其作为用户实例数据库附加适用于 SQL Server Express,是的。

如果您想使用“真正的”SQL Server,您仍然可以将 *.mdf 和 *.ldf 文件放入 App_Data - 您只是无法将它们自动附加到您的 SQL Server 实例,您必须使用以下命令手动执行此操作SQL Server Management Studio(在 SSMS 的对象资源管理器中,转到“数据库”节点并右键单击,选择“附加...”,然后导航到 App_Data 文件夹并选择 *.mdf 文件)。

所以,是的,在某种程度上,Visual Studio 有一个 App_Data 文件夹,它对于 SQL Server Express(默认情况下随 Visual Studio 安装)最有意义。

马克

Putting a *.mdf file into your App_Data and attaching it as a user instance database works only with SQL Server Express, yes.

If you want to use "real" SQL Server, you can still put your *.mdf and *.ldf files into App_Data - you just can't automagically attach them to your SQL Server instance, you'll have to do this manually using SQL Server Management Studio (in the Object Explorer of your SSMS, go to the "Databases" node and right-click, pick "Attach...." and then navigate to your App_Data folder and pick the *.mdf file).

So yes, in a way, Visual Studio has a App_Data folder that makes most sense with SQL Server Express (which is being installed with Visual Studio by default).

Marc

夜声 2024-08-13 11:43:25

您可以将 SQL Server 2005(或 2008)数据库与 Web 应用程序或网站项目一起使用。您可能可以将数据库文件(.mdf.ldf)放在 App_Data 文件夹中(请记住您需要附加数据库1 直接连接到 SQL Server — 自动连接文件仅适用于 Express)。

但您确实需要确保应用程序使用的数据连接设置为使用应用程序自己的 web.config 中定义的连接字符串。默认情况下,由于全局 machine.config2 设置成员资格的内容,成员资格提供程序默认为 App_Data 中的 SQL Express 数据库提供者使用连接
LocalSqlServer 在同一文件中设置为:

data source=.\SQLEXPRESS;Integrated Security=SSPI;
AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true

其中 |DataDirectory| 将在运行时被应用程序根目录中的 App_Data 替换。

总结应用程序(web.config,VS 的数据连接在设计器之外不使用)需要:

  • 使用 SQL Express。 App_Data 文件夹中的 .mdf,其连接字符串使用“AttachDBFilename”。
  • 将 SQL Server(完整)与在 SQL Server 中配置(持久)的数据库结合使用,并在 SQL Server 用户帐户所在的位置中使用数据文件(.mdf.ldf)可以访问。所有连接字符串都通过“数据源”(用于设置服务器名称)和“初始目录”来引用该数据库以设置数据库。 IIS 应用程序池的帐户需要能够访问 SQL Server。

1 使用 SQL Management Studio 来执行此操作。 (感谢其他答案提醒我。)

2 请参阅%SystemRoot%\\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config。这

You can use a SQL Server 2005 (or 2008) database with a Web Application or Web Site project. You can probably have the database files (.mdf, .ldf) in the App_Data folder (and remember you need to attach the database1 to SQL Server directly—the auto-connect file only works with Express).

But you do need to ensure the data connections used by the application are set to use connection strings defined in the application's own web.config. By default things like the membership provider default to a SQL Express database in App_Data due to the contents of the global machine.config2 setting the membership provider to use connection
LocalSqlServer which is set in the same file to be:

data source=.\SQLEXPRESS;Integrated Security=SSPI;
AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true

Where |DataDirectory| will be replaced at runtime by App_Data in the application root.

Summary the application, (web.config, VS's data connections are not used outside the designer) needs to either:

  • Use SQL Express. .mdf in the App_Data folder with a connection string using "AttachDBFilename".
  • Use SQL Server (full) with the database configured (persistently) in SQL Server with the data files (.mdf, .ldf) in a location that the SQL Server user account can access. All the connection strings reference that database via "Data Source" (to set server name) and "Initial Catalog" to set the database. The account for the IIS application pool needs to be able to access SQL Server.

1 Use SQL Management Studio to do this. (And thanks to the other answer for reminding me.)

2 See %SystemRoot%\\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config. The

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文