Private Sub InitializeDimNew_Click()
Dim s As New NotesSession
Call s.Initialize
MsgBox s.CommonUserName, , "Common user name"
End Sub
Private Sub InitializeCreateObject_Click()
Dim s As NotesSession
Set s = CreateObject("Lotus.NotesSession")
Call s.Initialize
MsgBox s.CommonUserName, , "Common user name"
End Sub
<HTML>
<HEAD>
<TITLE>Initialize Session</TITLE>
<SCRIPT LANGUAGE="VBScript">
Sub Button1_OnClick
dim s
Set s = CreateObject("Lotus.NotesSession")
Call s.Initialize
MsgBox s.CommonUserName,, "Common user name"
End Sub
</SCRIPT>
</HEAD>
<BODY>
<H3>Initialize Session and Print User Name</H3><HR>
<FORM>
<INPUT NAME="Button1" TYPE="BUTTON" VALUE="Click Here">
</FORM>
</BODY>
</HTML>
<script language="JScript">
var s;
s = new ActiveXObject("Lotus.NotesSession");
s.Initialize();
document.write(s.CommonUserName);
</script>
Private Sub DbDirectory_Click()
Dim s As New NotesSession
Dim dir As NotesDbDirectory
Dim db As NotesDatabase
s.Initialize
Set dir = s.GetDbDirectory("Doc/CAM/Notes")
Set db = dir.GetFirstDatabase(NOTES_DATABASE)
dbString = db.Title
dbCount = 1
While Not (db Is Nothing)
If dbCount > 12 Then
MsgBox dbString, , "Databases on " + dir.Name
dbString = db.Title
dbCount = 1
Else
dbString = dbString + Chr(10)
dbString = dbString + db.Title
dbCount = dbCount + 1
End If
Set db = dir.GetNextDatabase
Wend
MsgBox dbString, , "Databases on " + dir.Name
End Sub
<HTML>
<HEAD>
<TITLE>Initialize Session</TITLE>
<SCRIPT LANGUAGE="VBScript">
Sub Button1_OnClick
dim s, dir, db
Set s = CreateObject("Lotus.NotesSession")
Call s.Initialize
Set dir = s.GetDbDirectory("Doc/CAM/Notes")
Set db = dir.GetFirstDatabase(1247)
dbString = db.Title
dbCount = 1
While Not (db Is Nothing)
If dbCount > 12 Then
MsgBox dbString,, "Databases on " + dir.Name
dbString = db.Title
dbCount = 1
Else
dbString = dbString + Chr(10)
dbString = dbString + db.Title
dbCount = dbCount + 1
End If
Set db = dir.GetNextDatabase
Wend
MsgBox dbString,, "Databases on " + dir.Name
End Sub
</SCRIPT>
</HEAD>
<BODY>
<H3>Print Databases on Doc</H3><HR>
<FORM>
<INPUT NAME="Button1" TYPE="BUTTON" VALUE="Click Here">
</FORM>
</BODY>
</HTML>
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="; GENERATOR; " Content="; Microsoft; Visual; Studio; 6#; ">
</HEAD>
<BODY>
<%
dim s, dir, db
Set s = CreateObject("Lotus.NotesSession")
Call s.Initialize
dim serverName
serverName = ""
Set dir = s.GetDbDirectory(serverName)
Set db = dir.GetFirstDatabase(1247)
if (dir.Name <> "") then
Response.Write("<h2>" + "ON " + dir.Name + "</h2>")
else
Response.Write("<h2> ON local</h2>")
end if
Response.Write("<table border=1 bgcolor=#CCCCCC>")
Response.Write("<tr>")
Response.Write("<th>File Name")
Response.Write("<th>DB Title")
While Not (db Is Nothing)
Response.Write("<tr><td>")
Response.Write(db.FileName)
Response.Write("</td>")
Response.Write("<td>")
Response.Write(db.Title)
Response.Write("</td></tr>")
Set db = dir.GetNextDatabase
Wend
Response.Write("</table>")
%>
</BODY>
</HTML>
Private Sub DisplayItemValues_Click()
Dim s As New NotesSession
Dim db As NotesDatabase
Dim v As NotesView
Dim vn As NotesViewNavigator
Dim e As NotesViewEntry
Dim doc As NotesDocument
Call s.Initialize
Set db = s.GetDatabase("", "OverviewExamples.nsf")
Set v = db.GetView("All Documents")
Set vn = v.CreateViewNav()
Set e = vn.GetFirstDocument()
While Not (e Is Nothing)
Set doc = e.Document
subj = doc.GetFirstItem("Subject").Values
MsgBox subj(0), , "Subject"
cats = doc.GetFirstItem("Categories").Values
For Each cat In cats
MsgBox cat, , "Category"
Next
Set e = vn.GetNextDocument(e)
Wend
End Sub
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="; GENERATOR; " Content="; Microsoft; Visual; Studio; 6#; ">
</HEAD>
<BODY>
<%
Dim s 'As New NotesSession
Dim db 'As NotesDatabase
Dim v 'As NotesView
Dim vn 'As NotesViewNavigator
Dim e 'As NotesViewEntry
Dim doc 'As NotesDocument
Set s = CreateObject("Lotus.NotesSession")
Call s.Initialize
Dim serverName
serverName = ""
Set db = s.GetDatabase(serverName, "AllTypes.nsf")
Set v = db.GetView("All Documents")
Set vn = v.CreateViewNav()
Set e = vn.GetFirstDocument()
While Not (e Is Nothing)
Set doc = e.Document
Dim values, item1
Set item1 = doc.GetFirstItem("TextField")
values = item1.Values
Response.Write("<p>Subject: " + values(0) + "<br>")
Set item1 = doc.GetFirstItem("DateTimeField")
values = item1.Values
For Each dateTime In values
Response.Write("DateTime: " + CStr(dateTime))
Next
Set e = vn.GetNextDocument(e)
Wend
%>
</BODY>
</HTML>
<script language="JScript">
var s;
var dbdir;
var db;
var view;
var doc;
var forms = new Array(256);
s = new ActiveXObject("Lotus.NotesSession");
s.Initialize();
dbdir = s.getDbDirectory("");
db = dbdir.openDatabase("names");
view = db.getView("Groups");
doc = view.getFirstDocument();
forms = VBArray(doc.GetItemValue("Form")).toArray();
document.write(forms[0]);
</script>
Private Sub OpenDatabase_Click()
Dim s As New NotesSession
Dim dir As NotesDbDirectory
Dim db As NotesDatabase
Call s.Initialize
Set dir = s.GetDbDirectory("")
On Error GoTo errorHandler
Set db = dir.OpenDatabase(Form1.DatabaseName.Text)
MsgBox db.Title, , "Title"
Exit Sub
errorHandler:
If Err() = ERR_SYS_FILE_NOT_FOUND Then
MsgBox "Change the file name and try again", , _
"File not found"
Else
MsgBox "Error " & _
CInt("&H" & Right(Hex(Err()), 4)), , _
"Domino error"
End If
End Sub
Sub Button1_OnClick
On Error Resume Next
dim s, dir, db, ERR_SYS_FILE_NOT_FOUND
If Len(Hex(4003)) = 3 Then
ERR_SYS_FILE_NOT_FOUND = Clng("&H80040" & Hex(4003))
Else
ERR_SYS_FILE_NOT_FOUND = Clng("&H8004" & Hex(4003))
End If
Set s = CreateObject("Lotus.NotesSession")
Call s.Initialize
Set dir = s.GetDbDirectory("")
Set db = dir.OpenDatabase(Document.Form1.Text1.Value)
If Err.Number = 0 Then
MsgBox db.Title,, "Title"
Else
If Err.Number = ERR_SYS_FILE_NOT_FOUND Then
MsgBox "Change the file name and try again",, _
"File not found"
Else
MsgBox CInt("&H" & Right(Hex(Err.Number),4)),, _
"Domino error"
End If
End If
End Sub
<%@ Language=VBScript %>
<HTML>
<HEAD>
<META NAME="; GENERATOR; " Content="; Microsoft; Visual; Studio; 6#; ">
</HEAD>
<BODY>
<%
'URL http://yourserver/Demo9.asp?key=keyWord
Dim s 'As New NotesSession
Dim db 'As NotesDatabase
Dim v 'As NotesView
Dim vn 'As NotesViewNavigator
Dim e 'As NotesViewEntry
Dim doc 'As NotesDocument
Set s = CreateObject("Lotus.NotesSession")
Call s.Initialize
Dim serverName
serverName = ""
Response.Write("<h2>Full Text Search Result</h2>")
Dim dbName, keyWord
keyWord = Request.QueryString("key")
dbName = "employees.nsf"
Set db = s.GetDatabase(serverName, dbName)
If (db is Nothing) then
Response.Write("<p>Cannot find the database: " + dbName)
Else
Response.Write("<p>Database: " + db.FileName + "<br>")
Response.Write("Key Word: " + keyWord + "<br>")
End if
Call db.UpdateFTIndex(true)
Set dc = db.FTSearch(keyWord, 100)
Response.Write("Records: " + CStr(dc.Count) + "<br><br><br>")
Set doc = dc.GetFirstDocument()
Dim thisItem
If Not (doc is Nothing) then
Response.Write("<table border=1 bgcolor=#CCCCCC>")
Response.Write("<th>ID")
Response.Write("<th>First Name")
Response.Write("<th>Last Name")
Response.Write("<th>Department")
Response.Write("<th>Title")
End if
While Not (doc Is Nothing)
Response.Write("<tr>")
Set thisItem = doc.GetFirstItem("ID")
Response.Write("<td>" + thisItem.Text + "</td>")
Set thisItem = doc.GetFirstItem("FirstName")
Response.Write("<td>" + thisItem.Text + "</td>")
Set thisItem = doc.GetFirstItem("LastName")
Response.Write("<td>" + thisItem.Text + "</td>")
Set thisItem = doc.GetFirstItem("Department")
Response.Write("<td>" + thisItem.Text + "</td>")
Set thisItem = doc.GetFirstItem("Title")
Response.Write("<td>" + thisItem.Text + "</td>")
Set doc = dc.GetNextDocument(doc)
Response.Write("</tr>")
Wend
Response.Write("</table>")
%>
</BODY>
</HTML>
次は、ASP コードを起動するための HTML ファイルです。
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>
<BODY>
<form method=GET action="http://mkoma4/COM_AspSep28/Demo/Demo9.asp">
<h2>Full Text Search on Employees Database</h2>
<br>
<br>
<P>Input A Keyword:
<input name=key size=20>
<br>
<br>
<br>
<input type=reset value="Clear Form">
<input type=submit value="Submit">
</form>
</BODY>
</HTML>