TheVampire
Programmer
I've got a very simple SQL query that is not returning all the records it should return.
Here's how I set the database connection:
And here is the query to the data:
Now, at this point I would expect the tenants recordset to include all records that have the ACCESSNUMBER field set to the value I have for "Password" ( both are strings ). However, this is not the case, It often will only contain the first record in the database that matches.
To verify that the database actually does have more than one record, I can do this:
So, why does the SQL command that asks for the matching password only show one record, but the one that fetches all records and filters them with an If statement show all correctly?
Obvously I prefer the first method to work because with a large number of tenant records I have to do a lot of looping and this slows things down. But until I figure out why the first method is doing what it's doing, I have no other choice.
Now, I realize that Paradox 7.0 files are not fully supported by VB6 and it may very well be that I'm stuck with this, but I want to see what can be done first.
Thanks
Here's how I set the database connection:
Code:
DB.Mode = adModeReadWrite
DB.Open "Provider=MSDASQL;Driver={Microsoft Paradox Driver (*.db )};" & "DriverID=538;" & "Fil=Paradox 7.X;" & "DefaultDir=" & MyDatabasePath & ";" & "Dbq=" & MyDatabasePath & ";" & "CollatingSequence=ASCII"
And here is the query to the data:
Code:
TENANTS.ActiveConnection = DB
TENANTS.Source = "SELECT * FROM tenant WHERE ACCESSNUMBER = '" & Password & "'"
TENANTS.CursorType = adOpenKeyset
TENANTS.LockType = adLockOptimistic
TENANTS.CursorLocation = adUseServer
TENANTS.Open
Now, at this point I would expect the tenants recordset to include all records that have the ACCESSNUMBER field set to the value I have for "Password" ( both are strings ). However, this is not the case, It often will only contain the first record in the database that matches.
To verify that the database actually does have more than one record, I can do this:
Code:
TENANTS.ActiveConnection = DB
TENANTS.Source = "SELECT * FROM tenant"
TENANTS.CursorType = adOpenKeyset
TENANTS.LockType = adLockOptimistic
TENANTS.CursorLocation = adUseServer
TENANTS.Open
Do Until TENANTS.EOF = True
If (TENANTS.Fields("ACCESSNUMBER") = Password) Then
' here I count up the number of records and it matches what I should see.
End If
So, why does the SQL command that asks for the matching password only show one record, but the one that fetches all records and filters them with an If statement show all correctly?
Obvously I prefer the first method to work because with a large number of tenant records I have to do a lot of looping and this slows things down. But until I figure out why the first method is doing what it's doing, I have no other choice.
Now, I realize that Paradox 7.0 files are not fully supported by VB6 and it may very well be that I'm stuck with this, but I want to see what can be done first.
Thanks