打印本文 打印本文 关闭窗口 关闭窗口
第二课 SqlConnection对象(翻译)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数11088  更新时间:2007/11/14 13:12:47  文章录入:mintao  责任编辑:mintao
Integrated Security is secure when you are on a single machine doing development.  However, you will often want to specify security based on a SQL Server User ID with permissions set specifically for the application you are using.  The following shows a connection string, using the User ID and Password parameters:

当你在一个独立的机器上面做开发的时候,集成安全是安全的。然而,你通常希望指明所使用的应用程序的基于SQL Server用户ID的安全许可。下面显示的连接字符串使用了User IDPassword参数:

SqlConnection conn = new SqlConnection(
"Data Source=DatabaseServer;Initial Catalog=Northwind;User ID=YourUserID;Password=YourPassword");

Notice how the Data Source is set to DatabaseServer to indicate that you can identify a data base located on a different machine, over a LAN, or over the Internet.  Additionally, User ID and Password replace the Integrated Security parameter.

注意Data Source被设置为DatabaseServer来指示你能够指明位于不同机器――跨局域网或者Internet――的数据库。另外,User IDPassword替换调了集成安全参数。

Using a SqlConnection

使用SqlConnection

The purpose of creating a SqlConnection object is so you can enable other ADO.NET code to work with a data base.  Other ADO.NET objects, such as a SqlCommand and a SqlDataAdapter take a connection object as a parameter.  The sequence of operations occurring in the lifetime of a SqlConnection are as follows:

创建

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]  ...  下一页 >> 

打印本文 打印本文 关闭窗口 关闭窗口