如何在Visual Studio 2010中连接到Microsoft SQL Server数据库

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is more about using the Visual Studio environment to view databases on a SQL Server installation if you don’t have any database tools such as SQL Server Management Studio.  

本文档介绍如何连接到SQL Server和浏览其内容。 它适用于那些不熟悉Visual Studio和/或使用Microsoft SQL Server的用户。 它不是在代码中建立SQL Server数据库连接的指南。 如果您没有任何数据库工具(例如SQL Server Management Studio),则这与使用Visual Studio环境查看SQL Server安装上的数据库有关。

The most useful reason you may want to do this is that once you do establish your data connection in Visual Studio, you can use the drag-and-drop data functionality in Visual Studio for SQL Server.

您可能要执行此操作的最有用的原因是,一旦在Visual Studio中建立了数据连接,便可以在Visual Studio for SQL Server中使用拖放数据功能。

A handy tip:  many of these dialogs and menus are the same or very similar in Visual Studio 2008 and 2005.

一个方便的提示:在Visual Studio 2008和2005中,许多对话框和菜单是相同或非常相似的。

1)  Open Visual Studio

1)打开Visual Studio

2)  Click the Server Explorer tab from the left-hand pane (where you see the Toolbox--at the bottom of that pane you will see "Server Explorer")  

2)单击左侧窗格中的“ 服务器资源管理器”选项卡(在其中看到“工具箱”,在该窗格的底部,您将看到“服务器资源管理器”)

3)  Right-click Data Connections and choose Add Connection… from the context menu:  

3)右键单击“ 数据连接”,然后从上下文菜单中选择“ 添加连接… ”:

4)  In the Choose Data Source window, click Microsoft SQL Server.  

4)在“ 选择数据源”窗口中,单击“ Microsoft SQL Server”。


 


Note:注意:

Click Continue.  The 'Test Connection' pane will open.

点击继续 。 “测试连接”窗格将打开。

Server Name lets you type the name of the machine hosting SQL Server, or click the dropdown and you will see a list of all the visible instances of SQL Server on your network. 服务器名称允许您键入托管SQL Server的计算机的名称,或单击下拉列表,您将看到网络上所有可见SQL Server实例的列表。

b)  Log on to the server lets you specify which method is used to access the database.  Typically this is Windows Authentication, but your DBA will be able to help you if you’re unsure.

b)登录到服务器可以让您指定用于访问数据库的方法。 通常,这是Windows身份验证,但是如果您不确定,您的DBA将能够为您提供帮助。



c)  Select or enter a database name will let you type in the name, or you can click the dropdown and select it from among the databases that were found on the SQL Server.

c)选择或输入数据库名称将使您可以键入名称,也可以单击下拉列表并从SQL Server上找到的数据库中选择它。



d)  Test Connection is the best part – use it to confirm that your connection will work.  When you click it, you should either get "Test Connection Succeeded" or an error message indicating the problem.

d) 测试连接是最好的部分–使用它来确认您的连接可以工作。 单击它时,您应该得到“测试连接成功”或一条错误消息,指出问题所在。



e)  Click OK and you will be dropped back into Visual Studio

e)单击“确定”,您将被放回到Visual Studio中

Just use the plus signs next to each element to open/close the item and view objects on the server.

只需使用每个元素旁边的加号即可打开/关闭该项目并查看服务器上的对象。

NOTE:  The attached PDF includes screenshots...if this text isn't helpful, consider opening the attachment for a visual walkthrough.

注意:随附的PDF包括屏幕截图...如果此文本没有帮助,请考虑打开附件以进行直观演练。

SQLServerConnectionInVisualStudi.pdf SQLServerConnectionInVisualStudi.pdf

Hope this Article helps you with your database projects.

希望本文对您的数据库项目有所帮助。

翻译自: https://www.experts-exchange.com/articles/4882/How-to-connect-to-a-Microsoft-SQL-Server-database-in-Visual-Studio-2010.html

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值