我错在哪?请各位指教!(环境:VB6 SP5, WINDOWS2000 SP4)
'使数据库有Replicable属性
Public Function SetReplicable(strDB As String) As Integer
Dim prpReplicable As Property
Dim dbsTarget As Database
On Error GoTo ErrorHandler
Set dbsTarget = OpenDatabase(strDB)
'若属性已存在,则关闭错误处理
On Error Resume Next
'创建Replicable属性
Set prpReplicable = dbsTarget.CreateProperty("Replicable", dbText, "T")
'把该属性添加到属性集合中
dbsTarget.Properties.Append prpReplicable
'把该属性设置为True
dbsTarget.Properties("Replicable") = "T"
SetReplicable = 0
ErrorHandler:
Select Case Err
Case 0:
SetReplicable = 0
Exit Function
Case 3270:
Set prpReplicable = dbsTarget.CreateProperty("Replicab", dbText, "T")
dbsTarget.Properties.Append prpReplicable
Exit Function
Case Else:
MsgBox "Error " & Err & " : " & Error
SetReplicable = Err
Exit Function
End Select
End Function
'新建数据库副本
Public Function MakeAdditionalReplica(strReplicableDB As String, strNewReplica As String, intOptions As Integer) As Integer
Dim dbsTemp As Database
On Error GoTo ErrorHandler
Set dbsTemp = OpenDatabase(strReplicableDB)
' 如果在调用此函数时,intOptions处末给出参数,则忽略该参数项,默认建立一个完全
'的、可读/写的副本,否则就利用提供的参数按要求建立副本
If intOptions = 0 Then
dbsTemp.MakeReplica strNewReplica, "Replica of " & strReplicableDB
Else
dbsTemp.MakeReplica strNewReplica, "Replica of " & strReplicableDB, intOptions
End If
dbsTemp.Close
ErrorHandler:
Select Case Err
Case 0:
MakeAdditionalReplica = 0
Exit Function
Case Else:
MsgBox "Error " & Err & " : " & Error
MakeAdditionalReplica = Err
Exit Function
End Select
End Function
然后,我用下面的代码来设置,成功。可复制时,却提示:
error 3485 :由于数据库未经复制,无法复制对象。
我错在哪?
' 建立Replicable属性
If SetReplicable(App.path & "\abc.mdb") = 0 Then
MsgBox "设置Replicable成功!"
Else
MsgBox "属性设置失败!"
End If
'复制数据库副本
If MakeAdditionalReplica(App.path & "\abc.mdb", App.path & "\abc_rep.mdb", 0)
= 0 Then
MsgBox "副本生成成功!"
Else
MsgBox "没有生成副本!"
End If
[此贴子已经被作者于2004-5-8 10:54:25编辑过]
|