LOTUS CONNECTOR


例:FetchBatchSize プロパティ
次の例は、現在の CacheLimit と FetchBatchSize の値を表示し、ユーザー入力に従って新しい値を設定して新規値を表示するアクション (Click サブルーチン) を示しています。この例は FetchBatchSize が CacheLimit 以下であることを確認します。

Uselsx "*LSXODBC"
%INCLUDE "lsconst.lss"

Dim con As ODBCConnection
Dim qry As ODBCQuery
Dim result As ODBCResultSet

Sub Postopen(Source As Notesuidocument)
 Set con = New ODBCConnection
 Set qry = New ODBCQuery
 Set result = New ODBCResultSet
 Set qry.Connection = con
 Set result.Query = qry
 con.ConnectTo("ATDB")
 qry.SQL = "SELECT * FROM STUDENTS ORDER BY LASTNAME"
 result.Execute
 ...
End Sub

Sub Click(Source As Button)
 If Messagebox("Current settings" & Chr(10) & Chr(10) _
 & "Cache limit:" & result.CacheLimit & Chr(10) _
   & "Fetch batch size:" & result.FetchBatchSize, _
 MB_YESNO, "Do you want change?")= IDYES Then
   cLimit = Inputbox _
   ("Enter 0 for DB_NONE or size of cache", _
   "Cache limit?")
   If cLimit = 0 Then
     result.cacheLimit = DB_NONE
   Elseif cLimit > 0 Then
     result.cacheLimit = cLimit
   Else
     Messagebox  _
     "Cache limit must be 0 or positive integer"
     Exit Sub
   End If
   fbSize = Inputbox("Enter fetch batch size", _
     "Fetch batch size")
   If fbSize < 1 Then
     Messagebox _
     "Fetch batch size must be positive integer
     and not zero"
     result.FetchBatchSize = 1
   Elseif cLimit <> 0 And fbSize > cLimit Then
     result.FetchBatchSize = cLimit
     Messagebox "Fetch batch size reduced to" _
     & result.CacheLimit,, _
     "Fetch batch size cannot exceed cache limit"
   Else
     result.FetchBatchSize = fbSize
   End If
   Messagebox "New settings" & Chr(10) & Chr(10) _
   & "Cache limit:" & result.CacheLimit & Chr(10) _
   & "Fetch batch size:" & result.FetchBatchSize, , _
   "New settings"
 End If
End Sub

Sub Queryclose(Source As Notesuidocument, Continue As Variant)
 result.Close(DB_CLOSE)
 con.Disconnect
End Sub

関連項目