共用方式為


Status 屬性範例 (Field) (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  

下列範例會從文件開啟的記錄中刪除已知的欄位Status 屬性會先設定為 adFieldOK,然後設為 adFieldPendingUnknown

Attribute VB_Name = "StatusField"  

下列程式碼會從唯讀文件上開啟的記錄刪除欄位Status 將會設定為 adFieldPendingDelete更新時,刪除將會失敗,而且 Status 將會是 adFieldPendingDelete 加上 adFieldPermissionDeniedCancelUpdate 會清除擱置的 Status 設定。

Attribute VB_Name = "StatusField"  

另請參閱

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