InternetTimeout 属性示例 (VB)
重要
从 Windows 8 和 Windows Server 2012 开始,RDS 服务器组件不再包含在 Windows 操作系统中(有关详细信息,请参阅 Windows 8 和 Windows Server 2012 兼容性指南)。 RDS 客户端组件将在将来的 Windows 版本中删除。 避免在新开发工作中使用此功能,并计划修改当前使用此功能的应用程序。 使用 RDS 的应用程序应迁移到 WCF 数据服务。
此示例演示了 InternetTimeout 属性,该属性存在于 DataControl 和 DataSpace 对象上。 此示例使用 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)