Manage Learn to apply best practices and optimize your operations.

Rename a database with Lotus Script API

This Lotus Script code calls an undocumented function "NSFDbRename" in the nnotes.dll.

This Lotus Script code calls an undocumented function "NSFDbRename" in the nnotes.dll. Works successfully in Notes 4.6. Not tested in R5.

It accepts two parameters:
1. Database to be renamed (with optional server)
2. New database name (with optional server)

If you specify a server, it must be in the format:

Canonical_Server_Name!!path\database.nsf

In this case, both parameters MUST contain the canonical server name.

This function also uses the "OSLoadString" API call to convert an API error code into a string value.

If you need to use the same function written in "C", let me know and I will send you the C code.

Dennis Fry
[email protected]


Option Public
Option Explicit

Declare Function W32_NSFDbRename Lib "nnotes.dll" Alias "NSFDbRename" (Byval DbCurrent As String, Byval DbNew As String) As Integer
Declare Function W32_OSLoadString Lib "nnotes.dll" Alias "OSLoadString" (Byval hModule As Long, Byval StringCode As Integer, Byval retBuffer As String, Byval BufferLength As Integer) As Integer


Sub Initialize
     
     Dim iret As Integer
     Dim szError As String * 256
     Dim ErrorString As String
     Dim StrLen As Integer
     
'rename a database on SERVER/OU from "mail\mailfile.nsf" to "mail\mailfilenew.nsf"

     iret = W32_NSFDbRename("SERVER/OU!!mail\mailfile.nsf", "SERVER/OU!!mail\mailfilenew.nsf")
     If iret <> 0 Then
          ErrorString = ""
          szError = String$(256, 0)
          StrLen = W32_OSLoadString(0, iret, szError, 255)
          If Strlen <> 0 Then ErrorString = Left$(szError, StrLen)
          Print "Error " & iret & " (" & ErrorString & ")"
     End If
     
End Sub

Dig Deeper on Lotus Notes Domino Administration Tools

SearchWindowsServer
Search400
  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/Search400.com community. These cheat ...

SearchDataCenter
SearchContentManagement
Close