HELP with recordset exist

westerncj

New member
Joined
Feb 9, 2012
Messages
3
Programming Experience
Beginner
I need some help. I have 2 recordsets I'm comparing. I want to return false if they aren't equal. I'm not sure how to compare the two recordsets. I'm using a Select SP and and Exist SP. Can anyone help? I have some code commented out so just ignore it....


VB.NET:
   Private Function RunFixedAssetsUpdate() As Boolean
 
      Try
         Me.Cursor = Cursors.WaitCursor
 
         MyCorporateAssetList = FASTrackingAWCServer3.SP.FixedAssetsSelect.ExecuteList("WHERE LocNo = '116'", "")
 
         If sRtnErrMsg <> "" Then
            Me.Cursor = Cursors.Default
            MessageBox.Show("Error getting FixedAssets records from AWCServer3", "FixedAssets Update Error", MessageBoxButtons.OK, MessageBoxIcon.Stop)
            Return False
         Else
 
            For i As Integer = 0 To MyCorporateAssetList.Count - 1
               MyFASTrackingList.AddNew()
 
               With MyCorporateAssetList.Item(i)
                  .AssetID = MyCorporateAssetList.Item(i).AssetID
 
                  If FASTrackingExist.Exist.FixedAssets(MyCorporateAssetList.Item(i).AssetID) = False Then

                  Else
 
                     MyFASTrackingList.MarkOld()
                  End If
 
                  Dim Asset As FASTrackingTSSWork.List.FASTrackingSelect
                  Asset = FASTrackingTSSWork.SP.FASTrackingSelect.ExecuteList("AssetID = " & CStr(MyCorporateAssetList.Item(i).AssetID))
  
                  With MyFASTrackingList.Item(i)
                     .AssetID = MyCorporateAssetList.Item(i).AssetID
                     .Location = MyCorporateAssetList.Item(i).Location
                     .LocNo = MyCorporateAssetList.Item(i).LocNo.Trim
                     .AssetNo = MyCorporateAssetList.Item(i).AssetNo.Trim
                     .Description = MyCorporateAssetList.Item(i).Description.Trim
                     .AFENo = MyCorporateAssetList.Item(i).AFENo.Trim
                     .Dept = MyCorporateAssetList.Item(i).Dept.Trim
                     .SerialNo = MyCorporateAssetList.Item(i).SerialNo.Trim
                     .Op = MyCorporateAssetList.Item(i).Op.Trim
                     .NonOp = MyCorporateAssetList.Item(i).NonOp.Trim
                     .Disp = MyCorporateAssetList.Item(i).Disp.Trim
                     .UsefulLife = MyCorporateAssetList.Item(i).UsefulLife.Trim
                     .AcqDate = MyCorporateAssetList.Item(i).AcqDate
                     .AcqValue = MyCorporateAssetList.Item(i).AcqValue
                     .Depr = MyCorporateAssetList.Item(i).Depr
                     .NetBook = MyCorporateAssetList.Item(i).Netbook
                     .SalvValue = MyCorporateAssetList.Item(i).SalvValue
                     .Active = MyCorporateAssetList.Item(i).Active.Trim
                     .PlaceServ = MyCorporateAssetList.Item(i).PlaceServ
                  End With
               End With
 
                If i = MyCorporateAssetList.Count - 1 Then
                  If MyFASTrackingList.IsValid Then
                     'MyFASTrackingList.Save()
                     Return True
                  Else
                     Return False
                  End If
               End If
            Next i
         End If
 
         'End If
      Catch ex As Exception
         Me.Cursor = Cursors.Default
         MessageBox.Show(ex.Message, "Error updating local records", MessageBoxButtons.OK, MessageBoxIcon.Error)
         Return False
      Finally
         Me.Cursor = Cursors.Default
      End Try
 
   End Function
 
Ok so I got this far but I'm only going through the first record. How can I loop through all of them and hit my Next?

VB.NET:
[SIZE=2]         
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] i [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MyCorporateAssetList.Count - 1[/SIZE]
[SIZE=2]
            
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] t [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Integer[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = 0 [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MyLocalAssetList.Count - 1[/SIZE]
[SIZE=2]
               
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]With[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MyLocalAssetList.Item(t)[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .AssetID <> MyCorporateAssetList.Item(i).AssetID _[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .LocNo <> MyCorporateAssetList.Item(i).LocNo _[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .Location <> MyCorporateAssetList.Item(i).Location _[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .LocNo <> MyCorporateAssetList.Item(i).LocNo.Trim _[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .AssetNo <> MyCorporateAssetList.Item(i).AssetNo.Trim _[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .Description <> MyCorporateAssetList.Item(i).Description.Trim _[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .AFENo <> MyCorporateAssetList.Item(i).AFENo.Trim _[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .Dept <> MyCorporateAssetList.Item(i).Dept.Trim _[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .SerialNo <> MyCorporateAssetList.Item(i).SerialNo.Trim _[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .Op <> MyCorporateAssetList.Item(i).Op.Trim _[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .NonOp <> MyCorporateAssetList.Item(i).NonOp.Trim _[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .Disp <> MyCorporateAssetList.Item(i).Disp.Trim _[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .UsefulLife <> MyCorporateAssetList.Item(i).UsefulLife.Trim _[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .AcqDate <> MyCorporateAssetList.Item(i).AcqDate _[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .AcqValue <> MyCorporateAssetList.Item(i).AcqValue _[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .Depr <> MyCorporateAssetList.Item(i).Depr _[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .Netbook <> MyCorporateAssetList.Item(i).Netbook _[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .SalvValue <> MyCorporateAssetList.Item(i).SalvValue _[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .Active <> MyCorporateAssetList.Item(i).Active.Trim _[/SIZE]
[SIZE=2]
                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Or[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] .PlaceServ <> MyCorporateAssetList.Item(i).PlaceServ [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]                     
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]False[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]                     
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Return[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]True[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]                  
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]               
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]With[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]            
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]         
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][/COLOR][/SIZE]
 
G'd evening,
In the very first round it returns a value then it leaves the function. With the code as is, you will never get more than one loop.
G'd luck
 
Last edited:
Back
Top