使用NotesAPI更新数据库设计

‘Declare
Declare Function W32_NSFDbOpen Lib "nnotes.dll" Alias "NSFDbOpen" ( Byval dbName As String, hdb As Long ) As Integer
Declare Function W32_NSFDbClose Lib "nnotes.dll" Alias "NSFDbClose" ( Byval hdb As Long ) As Integer
Declare Function W32_NSFDbInfoGet Lib "nnotes.dll" Alias "NSFDbInfoGet" ( Byval hdb As Long, Byval dbInfo As String ) As Integer
Declare Sub W32_NSFDbInfoModify Lib "nnotes.dll" Alias "NSFDbInfoModify" ( Byval dbInfo As String, Byval what As Long, Byval newValue As String )
Declare Function W32_NSFDbInfoSet Lib "nnotes.dll" Alias "NSFDbInfoSet" ( Byval hdb As Long, Byval dbInfo As String ) As Integer
Declare Function W32_DesignRefresh Lib "nnotes.dll" Alias "DesignRefresh" ( Byval sourceServer As String, Byval hDb As Long, Byval dwFlags As Long, Byval null0 As Long, Byval null1 As Long) As Integer

Function designReplace( strTargetServer As String, strTargetFile As String, strTemplateName As String, strSourceServer As String, refreshNow As Integer ) As Integer
'strTargetServer is the server where the database to get new desig resides
'strTargetFile is the database
'strSourceServer is the server where the design is refreshed from
'refreshNow = True, starts refresh right away, otherwise youll have to wait for the server or do it manually.
 designReplace = False
 
 Dim Sdb As String
 Dim Tdb As String
 Dim hdb As Long
 Dim strDbInfo As String * 255
 Dim strDBtitle As String * 255
 Dim strDBtemplate As String * 255
 Dim rc As Integer
 Dim Force As Integer
 
'*** Build the path for target databases.
 If strTargetServer = "" Then
  Tdb$ = strTargetFile
 Else
  Tdb$ = strTargetServer & "!!" & strTargetFile
 End If
 
'*** Get the db info from target database
 rc% = W32_NSFDbOpen( Tdb$, hdb& )
 If rc% <> 0 Then
'Error opening target database
  Exit Function
 End If
 
 rc% = W32_NSFDbInfoGet( hdb&, strDbInfo )
 If rc% <> 0 Then
'Error retrieving database info
  Exit Function
 End If
 
 Call W32_NSFDbInfoModify( strDbInfo, 3, strTemplateName )
 
 rc% = W32_NSFDbInfoSet( hdb&, strDbInfo )
 If rc% <> 0 Then
'Error setting new design info
  Exit Function
 End If
 
 If refreshNow Then
'Initiate refresh immediately...
  rc% = W32_DesignRefresh( strSourceServer, hdb&, 1, 0, 0 )
 End If
 
 rc% = W32_NSFDbClose( hdb& )
 
 designReplace = True
End Function

Sub Initialize
 If designReplace( "project", "mail/admin.nsf", "", "project" , True ) Then
  Print "Sweet!"
 End If
End Sub
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值