Hey gang, thought I'd better let you know about this critical DAO error in VB6 with an Access 97 database...I'm currently trying to find a way to solve it, but someone please let me know if they have a solution!!
Situation: I'm currently developing a commercial app, which contains it's own customised report generator. Users can specify criteria etc.
Now assume I have two tables - "Cases" and "People".
Because of the open nature of the report generator, a user can generate absolute crap SQL - such as:
Situation: I'm currently developing a commercial app, which contains it's own customised report generator. Users can specify criteria etc.
Now assume I have two tables - "Cases" and "People".
Because of the open nature of the report generator, a user can generate absolute crap SQL - such as:
Code:
Select Cases.Key, People.Age, People.Gender FROM Cases, People, WHERE People.Gender = "Female" AND People.Age >= 1 AND People.Age <= 10 OR People.Age >= 11 AND People.Age >= 20 ORDER BY People.Gender ASC
[\code]
Told you it was rubbish!
Anyway, assume there's around 760 records in the "Cases" table, and around 900 records in the "People" table.
Obviously you're going to get a Cartesian product without creating proper joins - which is not a problem, as I've got checks in for this kind of thing.
The problem is, when this code executes the OpenRecordset method, as similar to below:
[code]
Set TABLE NAME = Database.OpenRecordset(SQL IN HERE, dbOpenDynaset)
[\code]
VB Freezes - it stops completely dead, and a CTRL-ALT-DEL is required.
It doesn't matter what table type you use or what options you use - dbSnapShot, dbReadOnly etc - you still get the freeze.
If the code does execute, it returns over 490,000 records!!
What I don't get is, just opening the recordset should not cause this problem - DAO should just open the recordset, and I should then be able to use recordcount, absoluteposition etc etc to do my checks.
I tried running this query in MS Access, using the exact same SQL, and MS Access also freezes in the same way as VB does.
Strange eh...I'll investigate and I will find a fix eventually, but if anyone knows anything please let me know!
Cheers gang.
Later,
Mokil.