InternetTimeout 屬性範例 (VB)

重要

從 Windows 8 和 Windows Server 2012 開始,Windows 作業系統中不再包含 RDS 伺服器元件 (請參閱 Windows 8 和 Windows Server 2012 相容性操作手冊以取得詳細資訊)。 未來的 Windows 版本將移除 RDS 用戶端元件。 請避免在新的開發工作中使用這項功能,並規劃修改目前使用這項功能的應用程式。 使用 RDS 的應用程式應該移轉至 WCF 資料服務

此範例示範存在於 DataControlDataSpace 物件上的 InternetTimeout 屬性。 此範例會使用 DataControl 物件,並將逾時設為 20 秒。

'BeginInternetTimeoutVB  
  
Public Sub Main()  
    On Error GoTo ErrorHandler  
  
    Dim dc As RDS.DataControl  
    Dim rst As ADODB.Recordset  
    Set dc = New RDS.DataControl  
  
    dc.Server = "https://MyServer"  
    dc.ExecuteOptions = 1  
    dc.FetchOptions = 1  
    dc.Connect = "Provider='sqloledb';Data Source='MySqlServer';" & _  
        "Initial Catalog='Pubs';Integrated Security='SSPI';"  
    dc.SQL = "SELECT * FROM Authors"  
     ' Wait at least 20 seconds  
    dc.InternetTimeout = 200  
  
    dc.Refresh  
     ' Use another Recordset as a convenience  
    Set rst = dc.Recordset  
    Do While Not rst.EOF  
       Debug.Print rst!au_fname & " " & rst!au_lname  
       rst.MoveNext  
    Loop  
  
    If rst.State = adStateOpen Then rst.Close  
    Set rst = Nothing  
    Set dc = Nothing  
    Exit Sub  
  
ErrorHandler:  
    ' clean up  
    If Not rst Is Nothing Then  
        If rst.State = adStateOpen Then rst.Close  
    End If  
    Set rst = Nothing  
    Set dc = Nothing  
  
    If Err <> 0 Then  
        MsgBox Err.Source & "-->" & Err.Description, , "Error"  
    End If  
  
End Sub  
'EndInternetTimeoutVB  

另請參閱

DataControl 物件 (RDS)
DataSpace 物件 (RDS)
InternetTimeout 屬性 (RDS)