简体   繁体   English

在哪里可以找到AdventureWorks.mdf或可以附加到数据库的任何其他mdf文件

[英]where can I find AdventureWorks.mdf or any other mdf file that I could attach to my database

I am trying to attach mdf file from codeplex site: http://msftdbprodsamples.codeplex.com/ 我正在尝试从Codeplex站点附加mdf文件: http : //msftdbprodsamples.codeplex.com/

The problem is that they have msi files, which I am clueless what they contribute, cause the database doesnt exist when I try to refer to it.. 问题是它们有msi文件,我不知道它们有什么作用,导致当我尝试引用它时数据库不存在。

And the other file that they have Adventure2008.mdf, is higher version that my Visualstudio 2010 allows to connect to. 他们拥有Adventure2008.mdf的另一个文件是Visualstudio 2010允许连接的更高版本。 What is the solution.. is there a simple mdf file that I can attach on my studio 2010 ultimate? 解决方案是什么..是否可以在Studio 2010 Ultimate上附加一个简单的mdf文件?

To be clear, database files can only be attached to a running SQL Server instance. 为了清楚起见,数据库文件只能附加到正在运行的SQL Server实例。 They cannot be attached to Visual Studio, since Visual Studio is not SQL Server. 它们不能附加到Visual Studio,因为Visual Studio不是SQL Server。 However, Visual Studio can connect to a SQL Server instance and then open any database that is attached to that SQL Server instance. 但是,Visual Studio可以连接到SQL Server实例,然后打开附加到该SQL Server实例的任何数据库。

The .msi files are installers . .msi文件是安装程序 If you run them, they will install code samples and the .mdf files on your computer. 如果运行它们,它们将在计算机上安装代码示例和.mdf文件。 You may choose a location where they are installed, or accept the defaults (the default is C:\\Program Files\\Microsoft SQL Server\\100\\Tools\\Samples\\ according to the documentation on the Codeplex project wiki ). 您可以选择它们的安装位置,也可以接受默认设置(根据Codeplex项目Wiki上的文档,默认设置为C:\\Program Files\\Microsoft SQL Server\\100\\Tools\\Samples\\ )。

SQL Server SQL服务器

After you have installed and located the .mdf files, you should run SQL Server Management Studio Express ( free download from Microsoft), connect to your local running instance of SQL Server and attach the .mdf files. 安装并找到.mdf文件后,应运行SQL Server Management Studio Express( 从Microsoft 免费下载 ),连接到本地正在运行的SQL Server实例并附加.mdf文件。

When you have successfully attached the databases, you can connect to SQL Server from within Visual Studio using the Server Explorer. 成功附加数据库后,可以使用服务器资源管理器从Visual Studio中连接到SQL Server。

SQL Server Express user instance SQL Server Express用户实例

If you don't want to permanently attach the database to SQL Server and don't want to use SQL Server Management Studio to manage your SQL Server instance and its attached databases, you should install SQL Server Express Edition and work with user instances . 如果您不想将数据库永久附加到SQL Server,并且不想使用SQL Server Management Studio来管理SQL Server实例及其附加数据库,则应安装SQL Server Express Edition并使用用户实例 This works by automatically and transparently attaching and detaching a database file to a child instance of SQL Server Express. 这是通过自动透明地将数据库文件附加和分离到SQL Server Express的子实例而起作用的。

For this you have to copy the database file (.mdf) to the App_Data folder in your ASP.NET project. 为此,您必须将数据库文件(.mdf)复制到ASP.NET项目中的App_Data文件夹中。 It should now show up in Server Explorer in Visual Studio. 现在,它应该显示在Visual Studio的Server Explorer中。

Note that this doesn't mean that the database is attached to Visual Studio, it just means that Visual Studio started a child instance of SQL Server Express and that child instance has attached only that particular database file. 请注意,这并不意味着数据库已附加到Visual Studio,仅意味着Visual Studio启动了SQL Server Express的子实例,并且该子实例仅附加了该特定数据库文件。 When you quit Visual Studio, the child instance will detach and quit as well. 当您退出Visual Studio时,子实例也将分离并退出。

See: Using SQL Server Express with ASP.NET 请参阅: 将SQL Server Express与ASP.NET一起使用

And the other file that they have Adventure2008.mdf, is higher version that my Visualstudio 2010 allows to connect to. 他们拥有Adventure2008.mdf的另一个文件是Visualstudio 2010允许连接的更高版本。

Visual Studio 2010 should allow you to connect to any existing SQL server databases; Visual Studio 2010应该允许您连接到任何现有的SQL Server数据库。 it will certainly connect up to Server 2008 R2, which is what I use. 它肯定会连接到Server 2008 R2,这就是我所使用的。

You haven't indicated which version(s)/edition(s) of SQL Server you have installed. 您尚未指出已安装的SQL Server版本。

SQL Server Management Studio. SQL Server管理Studio。 I havent got that... Visual Studio ultimate wont let me attach it.. why not to attach it simply, rather than being bothered connecting to my SQL server?!!? 我还没有... Visual Studio Ultimate不允许我附加它。为什么不简单附加它,而不是麻烦连接到我的SQL Server?!?

Have you looked at the Server Explorer window in VS 2010 (Ctrl + Alt + S or via the View menu)? 您是否在VS 2010中查看了Server Explorer窗口(Ctrl + Alt + S或通过“查看”菜单)? It allows you to do a lot of what Management Studio allows you to do, including creating new databases. 它允许您执行Management Studio允许您执行的许多操作,包括创建新数据库。

You said that it "won't let you attach it"... but haven't indicated how you're trying to or what errors you're getting when you do. 您说它“不会让您附加它” ...但是并没有指出您要尝试的方法或这样做时遇到的错误。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM