Code:
Public Sub RemoveBSDuplicateentry()
Dim strSQL As String
Dim lngCnt As Long
Dim rs As Recordset
Dim rs1 As Recordset
Dim uSQryAcss As String
Dim uSQrySql As String
Dim objDB As New RBDBModule.DBModule
Dim fname As String
Dim ftype As String
Dim status As Integer
Dim strSQL1 As String
Dim strSQL2 As String
Dim Count As Integer
Dim fpath As String
glngProcessSetID = glngDisplaySetID
strSQL = "SELECT * FROM Backupset WHERE [SetNameid]=" & glngProcessSetID & ""
If gintDbType = 0 Then
Set rs = db.OpenRecordset(strSQL)
ElseIf gintDbType = 1 Then
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
End If
Do Until rs.EOF
status = rs("status")
ftype = rs("Type")
fname = rs("filename")
fpath = rs("filepath") & "\" & fname
If status = 2 Then
If ftype = 2 Then
If gintDbType = 0 Then
strSQL1 = "SELECT * FROM Backupset WHERE [SetNameid]=" & glngProcessSetID & " AND Filepath Like '*" & fpath & "*'"
Set rs1 = db.OpenRecordset(strSQL1)
ElseIf gintDbType = 1 Then
strSQL2 = "SELECT * FROM Backupset WHERE [SetNameid]=" & glngProcessSetID & " AND Filepath Like '%" & fpath & "%'"
Set rs1 = db.OpenRecordset(strSQL2, dbOpenDynaset, dbSeeChanges)
End If
Count = rs1.RecordCount
'If Count > 0 Then
Do Until rs1.EOF
If gintDbType = 0 Then
uSQryAcss = "DELETE FROM [Backupset] WHERE [SetNameid]=" & glngProcessSetID & " AND [FilePath] Like '*" & fpath & "*' "
db.Execute uSQryAcss
ElseIf gintDbType = 1 Then
uSQrySql = "DELETE FROM [Backupset] WHERE [SetNameid]=" & glngProcessSetID & " AND [FilePath] Like '%" & fpath & "%' "
Set objDB = New RBDBModule.DBModule
lngCnt = objDB.UpdateRecordstoDB(uSQrySql, gsDbDatabase, gsDbServer, gsDbUser, gsDbPass)
End If
rs1.MoveNext
Loop
'End If
End If
End If
rs.MoveNext
Loop
rs.Close
[B][/B]
proc_exit:
On Error Resume Next
Set rs = Nothing
Exit Sub
proc_error:
clog.WriteLog "Error in:RemovebsDuplicateEntry()............"
GoTo proc_exit:
End Sub