Tips and Tricks - DB redirect

Hi all,

i had searched the forum and found no info on this, the i solved-it myself. So here is the trick if you want to redirect someone from one database to another…

In the postopen of the database script, do you validation to see if you want or not to redirect. if so, do a source.close in this event. Then, in your queryclose of the adtabase script, do your same validation and use ws.opendatabase to redirect to the new database !

Hope this helps someone

Sub Postopen(Source As Notesuidatabase)

Dim s As New NotesSession

Dim ws As New notesuiworkspace

Dim db As notesdatabase

Dim db_cluster As NotesDatabase

Dim profile As NotesDocument	

Dim db_cluster_path As String

Dim db_cluster_server As String



Set db = source.Database

Set profile = db.GetProfileDocument("prf")



Dim ServerName As New NotesName(db.Server)



db_cluster_path = db.FilePath

db_cluster_server = profile.prfClusterServer(0)

If (Ucase(ServerName.Common) <> Ucase(db_cluster_server)) And db_cluster_server <> "" Then

	Set db_cluster = s.GetDatabase(db_cluster_server,db_cluster_path)

	If Not db_cluster Is Nothing Then

		source.Close



	End  If

End If

End Sub

Sub Queryclose(Source As Notesuidatabase, Continue As Variant)

Dim s As New NotesSession

Dim ws As New notesuiworkspace

Dim db As notesdatabase

Dim db_cluster As NotesDatabase

Dim profile As NotesDocument	

Dim db_cluster_path As String

Dim db_cluster_server As String



Set db = source.Database

Set profile = db.GetProfileDocument("prf")



Dim ServerName As New NotesName(db.Server)



db_cluster_path = db.FilePath

db_cluster_server = profile.prfClusterServer(0)

If (Ucase(ServerName.Common) <> Ucase(db_cluster_server)) And db_cluster_server <> "" Then

	Set db_cluster = s.GetDatabase(db_cluster_server,db_cluster_path)

	If Not db_cluster Is Nothing Then

	Call ws.OpenDatabase(db_cluster_server,db_cluster_path)



End If

End Sub

Subject: Tips and Tricks - DB redirect

This is exactly what I was wanting to do…Thanks for this code!