共用方式為


Status 属性範例 (欄段) (VB)

下列範例會使用 Internet Publishing Provider,從讀取/寫入資料夾開啟檔。 RecordField 物件的 Status 屬性會先設定為 adFieldPendingInsert,然後更新為 adFieldOk

'BeginStatusFieldVB  
  
 ' to integrate this code replace the values in the source string  
  
Sub Main()  
  
   Dim File As ADODB.Record  
   Dim strFile As String  
   Dim Cnxn As ADODB.Connection  
   Dim strCnxn As String  
  
   Set Cnxn = New ADODB.Connection  
   strCnxn = "url=https://MyServer/"  
   Cnxn.Open strCnxn  
  
   Set File = New ADODB.Record  
   strFile = "Folder/FileName"  
   ' Open a read/write document  
   File.Source = strFile  
   File.ActiveConnection = Cnxn  
   File.Mode = adModeReadWrite  
   File.Open  
  
   Debug.Print "Append a couple of fields"  
  
   File.Fields.Append "chektest:fld1", adWChar, 42, adFldUpdatable, "fld1"  
   File.Fields.Append "chektest:fld2", adWChar, 42, adFldUpdatable, "fld2"  
  
   Debug.Print "status for the fields"  
   Debug.Print File.Fields("chektest:fld1").Status 'adfldpendinginsert  
   Debug.Print File.Fields("chektest:fld2").Status 'adfldpendinginsert  
  
    'turn off error-handling to verify field status  
   On Error Resume Next  
  
   File.Fields.Update  
  
   Debug.Print "Update succeeds"  
   Debug.Print File.Fields("chektest:fld1").Status 'adfldpendinginsert + adFieldUnavailable  
   Debug.Print File.Fields("chektest:fld2").Status 'adfldpendinginsert + adFieldUnavailable  
  
    ' resume default error-handling  
   On Error GoTo 0  
  
     ' clean up  
    File.Close  
    Cnxn.Close  
    Set File = Nothing  
    Set Cnxn = Nothing  
  
End Sub  
'EndStatusFieldVB  

下列範例會從從文件開啟的 Record 中刪除已知的 FieldStatus 屬性會先設定為 adFieldOK,然後 adFieldPendingUnknown

Attribute VB_Name = "StatusField"  

下列程式代碼會從唯讀檔上開啟 Record 刪除 Field狀態 會設定為 adFieldPendingDelete 。 在 Update,刪除將會失敗,狀態 將會 adFieldPendingDelete 加上 adFieldPermissionDeniedCancelUpdate 會清除擱置 狀態 設定。

Attribute VB_Name = "StatusField"  

另請參閱

Field 物件
Record 物件 (ADO)
Status 屬性 (ADO 字段)