423,688 Members | 1,889 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,688 IT Pros & Developers. It's quick & easy.

Delete duplicate file path from database if i include i wnt child node to delete

P: 1
Expand|Select|Wrap|Line Numbers
  1. Public Sub RemoveBSDuplicateentry()
  2.      Dim strSQL As String
  3.      Dim lngCnt As Long
  4.      Dim rs As Recordset
  5.      Dim rs1 As Recordset
  6.      Dim uSQryAcss As String
  7.      Dim uSQrySql As String
  8.      Dim objDB As New RBDBModule.DBModule
  9.      Dim fname As String
  10.      Dim ftype As String
  11.      Dim status As Integer
  12.      Dim strSQL1 As String
  13.      Dim strSQL2  As String
  14.      Dim Count As Integer
  15.      Dim fpath As String
  16.  
  17.      glngProcessSetID = glngDisplaySetID
  18.      strSQL = "SELECT * FROM Backupset WHERE [SetNameid]=" & glngProcessSetID & ""
  19.  
  20.  
  21.              If gintDbType = 0 Then
  22.                 Set rs = db.OpenRecordset(strSQL)
  23.              ElseIf gintDbType = 1 Then
  24.                 Set rs = db.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
  25.              End If
  26.  
  27.             Do Until rs.EOF
  28.                 status = rs("status")
  29.                 ftype = rs("Type")
  30.                 fname = rs("filename")
  31.                 fpath = rs("filepath") & "\" & fname
  32.                 If status = 2 Then
  33.                     If ftype = 2 Then
  34.                         If gintDbType = 0 Then
  35.                            strSQL1 = "SELECT * FROM Backupset WHERE [SetNameid]=" & glngProcessSetID & " AND Filepath Like '*" & fpath & "*'"
  36.                            Set rs1 = db.OpenRecordset(strSQL1)
  37.                         ElseIf gintDbType = 1 Then
  38.                                strSQL2 = "SELECT * FROM Backupset WHERE [SetNameid]=" & glngProcessSetID & " AND Filepath Like '%" & fpath & "%'"
  39.                                Set rs1 = db.OpenRecordset(strSQL2, dbOpenDynaset, dbSeeChanges)
  40.                         End If
  41.                         Count = rs1.RecordCount
  42.                         'If Count > 0 Then
  43.                             Do Until rs1.EOF
  44.                                 If gintDbType = 0 Then
  45.                                    uSQryAcss = "DELETE FROM [Backupset] WHERE [SetNameid]=" & glngProcessSetID & " AND [FilePath] Like '*" & fpath & "*' "
  46.                                    db.Execute uSQryAcss
  47.                                 ElseIf gintDbType = 1 Then
  48.                                        uSQrySql = "DELETE FROM [Backupset] WHERE [SetNameid]=" & glngProcessSetID & " AND [FilePath] Like '%" & fpath & "%' "
  49.                                        Set objDB = New RBDBModule.DBModule
  50.                                        lngCnt = objDB.UpdateRecordstoDB(uSQrySql, gsDbDatabase, gsDbServer, gsDbUser, gsDbPass)
  51.                                 End If
  52.                             rs1.MoveNext
  53.                             Loop
  54.                         'End If
  55.                     End If
  56.                 End If
  57.             rs.MoveNext
  58.             Loop
  59.             rs.Close
  60.  
  61. proc_exit:
  62.         On Error Resume Next
  63.             Set rs = Nothing
  64.         Exit Sub
  65. proc_error:
  66.  
  67. clog.WriteLog "Error in:RemovebsDuplicateEntry()............"
  68. GoTo proc_exit:
  69. End Sub
  70.  
Attached Images
File Type: jpg xxx.jpg (67.1 KB, 53 views)
Feb 3 '16 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.