
DATABASE
Use Script To Change The Replicaid Of A Database
Wil Conway 06.21.2000
Rating: -4.25- (out of 5)




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 path
ame of the database with the good replica ID." _ ,"Switch Replica ID Agent -- Source Database" ,"source estsample.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 server here") DestinationDatabase = Inputbox$ ("Enter the path
ame of the database with the replica ID that you would " _ & "like to change." ,"Switch Replica ID Agent -- Destination Database" ,"destination estsample.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.
|
 |
|
|
 |
|
 |