Tip

Replace Database Design With Lotusscript

This LotusScript function allows you to replace a database design
programmatically. Just provide server and file name for the template and target
databases, and you're set.

This will work in Windows 9x, NT and 2000 only. (server or workstation).

Disclaimer: this function uses undocumented Notes APIs. There is no guarantee
it will work properly on every scenario, nor in future Notes versions.
'ReplaceDesign:

Option Public
Option Declare

' Notes functions
Declare Function NSFDbOpen Lib "nnotes.dll" Alias "NSFDbOpen" ( Byval filename
As String, hdb As Long ) As Integer
Declare Function NSFDbClose Lib "nnotes.dll" Alias "NSFDbClose" ( Byval hdb As
Long ) As Integer
Declare Function DesignReplace Lib "nnotes.dll" Alias "DesignReplace" ( Byval
ht As Long, Byval hdb As Long, Byval dw1 As Long, Byval dw2 As Long, Byval dw3
As Long, Byval dw4 As Long ) As Integer

Sub ReplaceDesign( tpl As NotesDatabase, db As NotesDatabase )
Dim source As String
Dim target As String
Dim status As Integer
Dim ht As Long
Dim hdb As Long

' open source (template) database
If tpl.Server="" Then
source=tpl.FilePath
Else
source=tpl.Server & "!!" & tpl.FilePath
End If
status=NSFDbOpen( source, ht )
If status<>0 Then Error 1, "Failed to open " & source & " (error code=" &
status & ")"

' open target database
If db.Server="" Then
target=db.FilePath
Else
target=db.Server & "!!" & db.FilePath
End If
status=NSFDbOpen( target, hdb )
If status<>0 Then
NSFDbClose ht
Error 1, "Failed to open " & target & " (error code=" & status & ")"
End If

' perform the design replacement
status=DesignReplace( ht, hdb, 0, 1, 0, 0 )

NSFDbClose ht
NSFDbClose hdb

If status<>0 Then Error 1, "Error during replace design (error code=" & status
& ")"

End Sub

This was first published in November 2000

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.