Home > Domino Tips > Administrator > Database > Use Script To Change The Replicaid Of A Database
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

DATABASE

Use Script To Change The Replicaid Of A Database


Wil Conway
06.21.2000
Rating: -4.25- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


Use this code to change the replicaid on a database instead of making a new
copy. You could use this to make two copies of databases replicas of eachother
or visa versa. If you want to make two databases non replicas and don't want
to make a new copy due to size issues you can create a new blank database and
copy the replicaid from the new database to the existing one breaking the link
to it's replicas.

Code

%INCLUDE "LSERR.LSS"
Declare Function W32_NSFDbOpen Lib "nnotes.dll" Alias "NSFDbOpen" _
(Byval dbname As String, dbHandle As Long ) As Integer
Declare Function W32_NSFDbClose Lib "nnotes.dll" Alias "NSFDbClose" _
(Byval dbHandle As Long ) As Integer
Declare Function W32_NSFDBCREATE Lib "NNOTES.DLL" Alias "NSFDbCreate" _
(Byval dbname As String, Byval dbClass As Variant, Byval forceIt As Single) As
Integer
Declare Function W32_NSFDBREPLICAINFOSET Lib "NNOTES.DLL" Alias
"NSFDbReplicaInfoSet" _
(Byval dbHandle As Long, replInfoStruct As Long) As Integer
Declare Function W32_NSFDBREPLICAINFOGET Lib "NNOTES.DLL" Alias
"NSFDbReplicaInfoGet" _
(Byval dbHandle As Long, replInfoStruct As Long) As Integer

Sub Initialize
Dim SourceServer As String
Dim SourceDatabase As String
Dim DestinationServer As String
Dim DestinationDatabase As String
Dim db As NotesDatabase

SourceServer = Inputbox$ ("Enter the server name that the database with the
good replica ID resides on." _
,"Switch Replica ID Agent -- Source Server Name" ,"Your server here")
SourceDatabase = Inputbox$ ("Enter the pathname of the database with the good
replica ID." _
,"Switch Replica ID Agent -- Source Database" ,"sourcetestsample.nsf")
DestinationServer = Inputbox$ ("Enter the server name of the database with the
replica ID " _
& "that you would like to change." ,"Switch Replica ID Agent -- Destination
Server Name" _
,"Your

Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Database
LotusScript code rebuilds corrupted busytime.nsf file
How to move Notes databases off Domino 8 servers and save disk space
Top 10 Lotus Notes/Domino administration tips of 2008
Batch file runs scheduled Lotus Notes database maintenance tasks
Fix and update Lotus Notes documents with limited access
Programmatically replace the design of Lotus Notes databases
Add a program doc to compact Lotus Notes databases automatically
More efficient local Lotus Notes database replication
Remove orphaned Lotus Notes documents on Domino databases with a 'virtual delete'
Detect and fix 'Manager' access control list settings in Lotus Notes Domino

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


server here")
DestinationDatabase = Inputbox$ ("Enter the pathname of the database with the
replica ID that you would " _
& "like to change." ,"Switch Replica ID Agent -- Destination Database"
,"destinationtestsample.nsf")

If DestinationServer = "Local" Then
DestinationServer = ""
End If
If SourceServer = "Local" Then
SourceServer = ""
End If
Set db = New NotesDatabase("","")
Call db.Open(DestinationServer,DestinationDatabase)
If Not (db.Isopen) Then
Msgbox "Switch Replica ID Agent could not open " & DestinationServer & "!!" &
DestinationDatabase _
, 16,"Error:"
Exit Sub
Else
Call db.close
End If

Set db = New NotesDatabase ("","")
Call db.Open(SourceServer,SourceDatabase)
If Not (db.Isopen) Then
Msgbox "Switch Replica ID Agent could not open " & sourceserver & "!!" &
sourcedatabase _
, 16,"Error:"
Exit Sub
End If
Call db.close

Call
SwitchReplID(SourceServer,SourceDatabase,DestinationServer,DestinationDatabase)


End Sub


Function SwitchReplID(S_Server As String, S_Db As String, D_Server As String,
D_Db As String) As Long

Dim S_DbString As String
Dim D_DbString As String
Dim dbhandle As Long
Dim retNoteID As Long
Dim noteClass As Long
Dim replInfo(5) As Long
Dim replID1 As Long
Dim replID2 As Long
Select Case Ucase$(S_Server)
Case "LOCAL"
S_DbString = S_Db
Case "LOKAL"
S_DbString = S_Db
Case ""
S_DbString = S_Db
Case Else
S_DbString = S_Server + "!!" + S_Db
End Select

Select Case Ucase$(D_Server)
Case "LOCAL"
D_DbString = D_Db
Case "LOKAL"
D_DbString = D_Db
Case ""
D_DbString = D_Db
Case Else
D_DbString = D_Server + "!!" + D_Db
End Select

'====================================Get the replica info struct from Source
DB===============================================

REM "W32"
rc = W32_NSFDBOPEN(S_DbString, dbhandle&)
rc = W32_NSFDBREPLICAINFOGET(dbhandle&, replInfo(0))
replID1 = replInfo(0)
replID2 = replInfo(1)
rc = W32_NSFDBCLOSE(dbhandle&)

'=====================================Replace Replica ID on
Database===================================================
rc = W32_NSFDBOPEN(D_DbString, dbhandle&)
rc = W32_NSFDBREPLICAINFOGET(dbhandle&, replInfo(0))
replInfo(0) = replID1
replInfo(1) = replID2
rc = W32_NSFDBREPLICAINFOSET(dbhandle&, replInfo(0))
rc = W32_NSFDBCLOSE(dbhandle&)
'_______________________________________________________________________________
_______

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.




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.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts