从理论上讲,rsRecordSet.Status能判断
可以用rs.Status的属性来判断, (ADO2.8)
这个属性返回一个长整数。
adStateClosed = 0 Indicates that the object is closed.
adStateOpen = 1 Indicates that the object is open.
adStateConnecting = 2 Indicates that the object is connecting.
adStateExecuting = 4 Indicates that the object is executing a command.
adStateFetching = 8 Indicates that the rows of the object are being retrieved.
可是以下程序,在数据集关闭时,出错---数据集关闭不可操作。
Dim TextRecordSet As ADODB.Recordset, LineRecordSet As ADODB.Recordset
Set TextRecordSet = New ADODB.Recordset
TextTitleVar = Array("ObjectID", "Backward", "Height", "pp0", "pp1", "pp2", "Layer", "Linetype", "LinetypeScale", "Lineweight", "ObliqueAngle", "OwnerID", "PlotStyleName", "Rotation", "ScaleFactor", "StyleName", "ppp0", "ppp1", "ppp2", "TextString", "Alignment", "UpsideDown", "Visible")
For jj = 0 To 22
TextRecordSet.Fields.Append TextTitleVar(jj), adBSTR
Next jj
TextRecordSet.Open
TextRecordSet.AddNew
Debug.Print TypeName(TextRecordSet), TextRecordSet.RecordCount
'TextRecordSet.Close
Debug.Print TextRecordSet.Status
可以用rs.Status的属性来判断, (ADO2.8)
这个属性返回一个长整数。
adStateClosed = 0 Indicates that the object is closed.
adStateOpen = 1 Indicates that the object is open.
adStateConnecting = 2 Indicates that the object is connecting.
adStateExecuting = 4 Indicates that the object is executing a command.
adStateFetching = 8 Indicates that the rows of the object are being retrieved.
可是以下程序,在数据集关闭时,出错---数据集关闭不可操作。
Dim TextRecordSet As ADODB.Recordset, LineRecordSet As ADODB.Recordset
Set TextRecordSet = New ADODB.Recordset
TextTitleVar = Array("ObjectID", "Backward", "Height", "pp0", "pp1", "pp2", "Layer", "Linetype", "LinetypeScale", "Lineweight", "ObliqueAngle", "OwnerID", "PlotStyleName", "Rotation", "ScaleFactor", "StyleName", "ppp0", "ppp1", "ppp2", "TextString", "Alignment", "UpsideDown", "Visible")
For jj = 0 To 22
TextRecordSet.Fields.Append TextTitleVar(jj), adBSTR
Next jj
TextRecordSet.Open
TextRecordSet.AddNew
Debug.Print TypeName(TextRecordSet), TextRecordSet.RecordCount
'TextRecordSet.Close
Debug.Print TextRecordSet.Status
但是对于枚举,他的值是1、2、4、8这样递增的,就要考虑组合的可能了
比如Status 是5,也就是 adStateExecuting Or adStateOpen
这个时候,状态 是open ,同时正在执行Execute