次の方法で共有


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"  

次のコードは、読み取り専用ドキュメントで開かれた レコード から フィールド を削除します。 状態 は adFieldPendingDelete に設定されます。 更新では、削除は失敗し、adFieldPendingDelete と adFieldPermissionDenied 状態 されます。 CancelUpdate は、保留中の 状態 設定をクリアします。

Attribute VB_Name = "StatusField"  

関連項目

Field オブジェクトの
Record オブジェクト (ADO)
Status プロパティ (ADO フィールド)