Tip

Rename a database with Lotus Script API

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
noteshelp@bigpond.com


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

This was first published in October 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.