Share via


Catalog ActiveConnection 속성 예제(VB)

ActiveConnection 속성을 열려 있는 유효한 연결로 설정하면 카탈로그가 "열립니다". 열려 있는 카탈로그에서 해당 카탈로그에 포함된 스키마 개체에 액세스할 수 있습니다.

' BeginOpenConnectionVB  
Sub Main()  
    On Error GoTo OpenConnectionError  
  
    Dim cnn As New ADODB.Connection  
    Dim cat As New ADOX.Catalog  
  
    cnn.Open "Provider='Microsoft.Jet.OLEDB.4.0';" & _  
        "Data Source= 'Northwind.mdb';"  
    Set cat.ActiveConnection = cnn  
    Debug.Print cat.Tables(0).Type  
  
    'Clean up  
    cnn.Close  
    Set cat = Nothing  
    Set cnn = Nothing  
    Exit Sub  
  
OpenConnectionError:  
  
    Set cat = Nothing  
  
    If Not cnn Is Nothing Then  
        If cnn.State = adStateOpen Then cnn.Close  
    End If  
    Set cnn = Nothing  
  
    If Err <> 0 Then  
        MsgBox Err.Source & "-->" & Err.Description, , "Error"  
    End If  
End Sub  
' EndOpenConnectionVB  

ActiveConnection 속성을 유효한 연결 문자열로 설정하면 카탈로그도 "열립니다".

Attribute VB_Name = "Catalog"  

참고 항목

ActiveConnection 속성(ADOX)
카탈로그 개체(ADOX)
테이블 개체(ADOX)
Tables 컬렉션(ADOX)
Type 속성(테이블)(ADOX)