Ado.net 介绍:SqlConnection类的属性
Ado.net 2.0中SqlConnection类共拥有10属性12方法2事件。此篇介绍下SqlConnection类的属性

1:ConnectionString
String/控制SqlConnection对象如何连接到数据源

2:ConnectionTimeout
Int32/SqlConnection对象尝试连接到数据源时等待的时间/秒(只读)

3:Database
String/连接数据库的名称(只读)

4:DataSource
String/连接数据库的位置(只读)即Sql地址

5:FireInfoMessageEventOnUserErrors
Boolean/发生错误时是否激发InfoMessage

6:PacketSize
Int32/与Sql通信时所使用的数据包大小(只读)

7:ServerVersion
String/返回数据源版本(只读)

8:State
ConnectionState/指示Sqlconnection对象当前状态(只读)

9:StatisticsEnabled
Boolean/控制是否为该连接启用统计

10:WorkstationID
String/返回数据库客户端的名称

代码:

  1. conn.Open();
  2.         Response.Write(conn.ConnectionString + "<br />");
  3.         Response.Write(conn.ConnectionTimeout + "<br />");
  4.         Response.Write(conn.Database + "<br />");
  5.         Response.Write(conn.DataSource + "<br />");
  6.         Response.Write(conn.FireInfoMessageEventOnUserErrors + "<br />");
  7.         Response.Write(conn.PacketSize + "<br />");
  8.         Response.Write(conn.ServerVersion + "<br />");
  9.         Response.Write(conn.State + "<br />");
  10.         Response.Write(conn.StatisticsEnabled + "<br />");
  11.         Response.Write(conn.WorkstationId + "<br />");

, , ,

Del.icio.us Google书签 Digg Live Bookmark Technorati Furl Yahoo书签 Facebook 百度搜藏 新浪ViVi 365Key网摘 天极网摘 和讯网摘 博拉网 POCO网摘 添加到饭否 QQ书签 Digbuzz我挖网

1 Comment so far...

  1. PlanetaJob

    Красиво написано, мне понравилось.

Leave a reply?