共用方式為


OdbcLoggingSection 類別1

指定透過 OPEN Database Connectivity (ODBC) 連線,將 IIS 事件記錄至資料庫的組態設定。

Syntax

class OdbcLoggingSection : ConfigurationSection  

方法

下表列出 類別所 OdbcLoggingSection 公開的方法。

名稱 描述
GetAllowDefinition (繼承自 ConfigurationSection.)
GetAllowLocation (繼承自 ConfigurationSection。)
RevertToParent (繼承自 ConfigurationSection。)
SetAllowDefinition (繼承自 ConfigurationSection。)
SetAllowLocation (繼承自 ConfigurationSection。)

屬性

下表列出 類別所 OdbcLoggingSection 公開的屬性。

名稱 描述
DataSource 讀取/寫入 string 值,指定寫入記錄檔之資料庫的系統 DSN (資料來源名稱) 。 預設值為 「InternetDb」。
Location (繼承自 ConfigurationSection .) 索引鍵屬性。
Password 讀取/寫入 string 值,指定用於在事件記錄期間寫入資料庫的 ODBC 資料庫密碼。
Path (繼承自 ConfigurationSection .) 索引鍵屬性。
SectionInformation (繼承自 ConfigurationSection。)
TableName 讀取/寫入 string 值,指定在事件記錄期間寫入資訊的 ODBC 資料庫資料表名稱。 預設值為 「InternetLog」。
UserName 讀取/寫入 string 值,指定用於在事件記錄期間寫入資料庫的 ODBC 資料庫使用者名稱。 預設值為 「InternetAdmin」。

子類別

這個類別不包含子類別。

備註

ODBC 記錄允許將 IIS 資料記錄到本機 Microsoft Access 資料庫或本機或遠端 Microsoft SQL Server資料庫。

範例

下列程式碼範例會指定 、 TablenameUsernamePassword 屬性的新值 DataSource 。 協助程式函式會顯示變更前後的值。

' Connect to the WMI WebAdministration namespace.  
Set oWebAdmin = GetObject( _  
    "winmgmts:root\WebAdministration")  
  
' Get the ODBCLoggingSection.  
Set oSection = oWebAdmin.Get("OdbcLoggingSection.Path=" & _  
    "'MACHINE/WEBROOT/APPHOST',Location=''")  
  
' Display the class name of the section.  
WScript.Echo "[ " & oSection.Path_.Class & " ]"  
  
' Display the initial values.  
Call DisplayValues("Initial Values", oSection)  
  
' Specify new ODBCLoggingSection property values.  
oSection.DataSource = "ODBCLoggingDB"  
oSection.TableName = "ODBCLoggingTable"  
oSection.Username = "ODBCLoggingAdmin"  
oSection.Password = "ODBCLoggingPassword"  
  
' Save the values to configuration.  
oSection.Put_  
  
' Refresh the oSection object variable with the new values.  
oSection.Refresh_  
  
' Show the changed values.  
Call DisplayValues("New Values", oSection)  
  
' ==== DisplayValues helper function. ====  
Function DisplayValues(HeadingText, oSection)  
    ' Display a heading.  
    WScript.Echo  
    WScript.Echo HeadingText  
    WScript.Echo String(Len(HeadingText), "-")  
  
    ' Display section properties.  
    WScript.Echo "Path: " & oSection.Path  
    WScript.Echo "Location: " & oSection.Location  
    WScript.Echo "DataSource: " & oSection.DataSource  
    WScript.Echo "TableName: " & oSection.TableName  
    WScript.Echo "Username: " & oSection.Username  
    WScript.Echo "Password: " & oSection.Password  
End Function  
  

繼承階層架構

ConfigurationSection

OdbcLoggingSection

規格需求

類型 描述
Client - Windows Vista 上的 IIS 7.0
- Windows 7 上的 IIS 7.5
- Windows 8 上的 IIS 8.0
- Windows 10上的 IIS 10.0
伺服器 - Windows Server 2008 上的 IIS 7.0
- Windows Server 2008 R2 上的 IIS 7.5
- Windows Server 2012 上的 IIS 8.0
- Windows Server 2012 R2 上的 IIS 8.5
- Windows Server 2016上的 IIS 10.0
產品 - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0
MOF 檔案 WebAdministration.mof

另請參閱

CentralBinaryLogFile 類別
CentralW3CLogFile 類別
ConfigurationSection 類別
HttpLoggingSection 類別
LogSection 類別
SiteLogFile 類別
如何在 IIS 中設定 ODBC 記錄