接前一个例子:
Connection 对象的Attributes属性:代表数据库连线的状态,由以下值相加,预设值为0:
&H00020000:正在呼叫CommitTrans。
&H00020000:正在呼叫RollbackTrans。
State属性:显示对象的状态:
0:对象已经关闭。
1:对象已经开启。
让我们看一个於ASP程式码当中使用Attributes/State属性的例子。
譬如ASP程式码rs17.asp如下:
1
2
3Set conn1 = Server.CreateObject("ADODB.Connection")
4
5conn1.Open "DBQ="& Server.MapPath("ntopsamp.mdb") &";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;"
6
7Response.Write "
<br/>
1conn1.Attributes: " & conn1.Attributes
2
3Response.Write "
<br/>
1conn1.State: " & conn1.Attributes
2
3Set rs2 = Server.CreateObject("ADODB.Recordset")
4
5rs2.Open "产品",conn1,1,1
6
7For Each fld In rs2.Fields
8
9Response.Write "
<br/>
1" & fld.Name & "=" & hex(fld.Attributes)
2
3Next
4
以上的 ASP程式码rs17.asp,於用户端使用浏览器,浏览执行的结果,For Each fld In rs2.Fields取得所有字段的讯息。显示:
字段类型为文字text字段、日期时间date 字段、整数int字段、备注memo字段,为可写入资料(&H00000004)、可接受Null的资料值(&H00000020)、可能读取到此字段为Null的资料值(&H00000040)。
字段类型为日期时间date 字段、整数int字段,为固定长度的资料(&H00000010)。
字段类型为备注memo字段,为长位元(long binary)字段(&H00000040)。