简体   繁体   English

将数据库添加到我的Visual Studio 2008项目中说我需要sql server express吗?

[英]Adding a database to my Visual Studio 2008 project says I need sql server express?

When I try to add a new Sql Server Database file to my Visual Studio project, it tells me that I need to have Sql Server 2005 Express installed even though I have Sql Server 2005 Developer already? 当我尝试将新的Sql Server数据库文件添加到我的Visual Studio项目时,它告诉我即使我已经安装了Sql Server 2005 Developer,我也需要安装Sql Server 2005 Express? Is this by design and if so, why did Microsoft do it? 这是设计,如果是这样,为什么微软这样做? and if it is not by design, what is the solution to fix it? 如果不是设计,解决它的解决方案是什么?

If you are going to add a database to your project, it is going to try and add one of the SQL Express type. 如果要将数据库添加到项目中,它将尝试添加一种SQL Express类型。 If you are using an actual SQL Server 2005 instance running, you want to CONNECT to it, you can't just add it to your project. 如果您正在使用实际的SQL Server 2005实例运行,您想要连接到它,您不能只是将它添加到您的项目。

What you will want to do is add a connection string (it will contain the basic connection info including location, database name, authentication properties, etc.) in your web.config and then you will be able to reference that connection string when trying to open a connection to the database. 您要做的是在web.config中添加一个连接字符串(它将包含基本连接信息,包括位置,数据库名称,身份验证属性等),然后您将能够在尝试时引用该连接字符串打开与数据库的连接。

Edit : You can use W3 Schools and their ASP.NET database tutorial for more information. 编辑 :您可以使用W3 Schools及其ASP.NET数据库教程获取更多信息。

Edit 2 : The author of the question asked a good follow-up in the comments and I wanted to make sure this was visible to future viewers without having to scour the comments. 编辑2 :问题的作者在评论中提出了一个很好的跟进,我想确保未来的观众可以看到这一点,而不必搜索评论。

The question Xaisoft posed was "Just out of curiosity. What if you don't want to add a connection, but you want to add a database? Do we have a choice?" Xaisoft提出的问题是“只是出于好奇。如果你不想添加连接但你想添加数据库怎么办?我们有选择吗?”

Answer : When you try to add a database, you are trying to add a full-blown database that will remain with the project regardless of where it is hosted (given that the host can run SQL Server Express instances). :当您尝试添加数据库时,您尝试添加一个完整的数据库,该数据库将保留在项目中,而不管它在何处托管(假设主机可以运行SQL Server Express实例)。 If you want to do that, you need to have SQL Server Express installed. 如果要这样做,则需要安装SQL Server Express。

Connecting to a database will allow you to point to the location of an existing SQL Server 2005 database anywhere (as long as you can properly authenticate). 连接到数据库将允许您指向任何位置的现有SQL Server 2005数据库的位置(只要您可以正确进行身份验证)。 I should also mention that regardless of what method you use, you will still need to learn about connecting. 我还要提一下,无论你使用什么方法,你仍然需要学习连接。

Even if you have a SQL Server Express DB packaged with your project, you will still need to use connectionstrings to establish a connection to that database so that you can then use queries and such on it. 即使您的项目打包了SQL Server Express数据库,您仍然需要使用连接字符串来建立与该数据库的连接,以便您可以在其上使用查询等。

In addition to TheTXI's answer, when adding a database to VS2008 project it will try to use an "Attached Database", one that is not (permanently) registered with the server but belongs to your project instead. 除了TheTXI的答案,在向VS2008项目添加数据库时,它将尝试使用“附加数据库”,这个数据库不是(永久)注册到服务器但是属于您的项目。 It will be copied to your Bin folder on build. 它将在构建时复制到Bin文件夹。 I believe it is this kind of Database is not supported in the DE edition. 我相信DE版本不支持这种数据库。

To use an existing Database (with the VS tools), choose Data| 要使用现有数据库(使用VS工具),请选择“数据”| Add a DataSource and then select Database in the Wizard. 添加一个DataSource,然后在向导中选择Database。

And you can create a new Database using the Server Explorer window, which offers a subset of the Management Studio. 您可以使用“服务器资源管理器”窗口创建新数据库,该窗口提供Management Studio的子集。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Visual Studio 2008工具向特定用户授予对SQL Server Express数据库的访问权限? - How do I grant access to my SQL Server Express database to a specific user with Visual Studio 2008 tools? Visual Studio 2008 Web Express:创建新的SQL Server数据库 - Visual Studio 2008 web express: create new SQL Server database 通过Visual Studio Professional 2008连接到AdventureWorks数据库(SQL Server 2005 Express) - Connecting to AdventureWorks database (SQL Server 2005 Express) through Visual Studio Professional 2008 我已经无法在Visual Studio Express for Web上创建新的SQL Server数据库选项 - i have create new sql server database option unable on visual studio express for web 如何在ASP.NET Core项目中指向我的完整SQL Server Express数据库? - How do I point to my full SQL Server Express database in ASP.NET Core project? 尝试从 Visual Studio Express 2008 发布项目时出错 - Errors attempting to publish a project from Visual Studio Express 2008 如何在Visual Studio中添加SQL Server数据库文件(.mdf)而不安装SQL Server Express Edition? - How to add SQL Server database file (.mdf) in Visual Studio without installing SQL Server Express Edition? IIS7应用程序使用了错误的SQL Server 2008 Express数据库 - IIS7 application using wrong SQL Server 2008 Express database 如何在SQL Server Express 2008中创建新数据库并允许连接? - How to create new database in SQL Server Express 2008 and allow for connecting? 将DateTime变量传递到Visual Studio 2008中的SQL Server存储过程中 - Passing DateTime variables into SQL Server stored procedures in Visual Studio 2008
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM