records comparison with


Sep 30, 2004
Programming Experience
i am new to and i have to rewrite a vb6 project.
I need to read from an indexed recordset one record at a time and compare data with records of another indexed recordset; if data are different or a record is missing I write a line of error in a list box.
Which is the best way to do this with and ? Could anyone help me with some code examples ?

This is my old vb6 code with ado

the record of rst1 and rst2 have these four fields :

with rst1
do until .eof array(!Article, !Colour, !Size), adseekfirsteq
if rst2.eof then
...write error record missing
if rst2!quantity <> rst1!quantity then
... write error quantity is different
end if
end if
end with

Thank you
I don't have notion such as Microsoft ACCESS treated i'm develop with sql server however some things to have itself seriously changed on
e.g. there are no more recordsets....
It's really hard to explain this, but if you really transfer from vb6 then i recommend you:
Buy as fast as possible a book....

It's hard to say where to begin....:)
I do agree with MatrixMatrix that you need to find a book and do some reading, but here is some code that may help you solve your problem:

' rst1 is now DataSet1 not a recordset
' rst2 is now DataSet2 not a recordset
' Can do this with just one DataSet as well 
' since a dataset supports multiple DataTables, 
' but I thought I'd keep it as close to the original as I could.
' you will have to find the code to load the DataSets with the required Data

Dim table1 as DataTable
Dim table2 as DataTable
table1 = DataSet1.Tables("TableName")
table2 = DataSet2.Tables("TableName")

Dim myRow as DataRow
For Each myRow in table1.Rows
   Dim strSearchExpression as String
   strSearchExpression = "Article = '" & myRow.Item("Article") & "' AND "
   strSearchExpression &= "Colour = '" & myRow.Item("Colour") & "' AND "
   strSearchExpression &= "Size = '" & myRow.Item("Size") & "'"

   Dim foundRows() As DataRow
   ' Use the Select method to find all rows matching the filter.
   foundRows = table2.Select(strSearchExpression)

   if foundrows.Count = 0 then
      ...write error record missing
      if myRow.Item("Quantity") <> foundRows(0).Item("Quantity") then
         ... write error quantity is different
      end if
   End If

Please note that I have noted tested this code as I do not have appropriate data, and alot of this was written from memory, you may have to read the help files if you run into problems.

Please not that it does not matter if the data comes from Access, SQL, Oracle, MySQL, a Text File, Excel File, or anywhere else. All that matters is that you are able to correctly load the data into a DataSet. Please think of a DataSet as an "in memory database"
Last edited:
Thank you very much, i put the code in my project with some changes and it works ok.
I think foundrows.count is foundrows.length instead, isn't it?

However I ordered a big book about

Thank you, bye
Yeah That seems right that it should be length because it is an array object.....

Have fun reading the book, and feel free to keep on posting here.

Also Google is a pretty good resource....