Link to home
Start Free TrialLog in
Avatar of Sheldon Livingston
Sheldon LivingstonFlag for United States of America

asked on

Why does changing a query cause a program to crash.

The query below returns -1 as a record count.

           
SQLQuery = "select somast.fduedate, somast.fsono, Description,   dateCreated as LastScanDate,sum(fquantity) as doorTotal " +
                    "from somast " +
                    "left outer join soitem on somast.fsono = soitem.fsono " +
                    "left outer join DoorTrak.dbo.Transactions on left(somast.fsono, 6) = left(DoorTrak.dbo.Transactions.SO, 6) " +
                    "left outer join DoorTrak.dbo.Entities on DoorTrak.dbo.Transactions.userID = DoorTrak.dbo.Entities.entityID " +
                    "where somast.fstatus = 'Open'  and somast.fduedate >= '2-12-2018' " +
                    "and(fprodcl in ('SE', 'SD', 'SL', 'SM', 'SR', 'SS', 'ST', 'LV')) " +
                    "and dateCreated in (select max(dateCreated) from DoorTrak.dbo.Transactions where left(somast.fsono, 6) = left(DoorTrak.dbo.Transactions.SO, 6) )  " +
                    "group by somast.fsono, fcompany, somast.fduedate, forderdate, fordername, fprint_dt, dateCreated , Description " +
                    "order by somast.fduedate";

Open in new window


The query below will return a record count of 9,920.
           
SQLQuery = "select * from somast where fduedate > '2/12/2018'";

Open in new window


Anyone have an idea as to why this would happen?  I would think that the cursor location wouldn't matter from one query to the next.
Avatar of kaufmed
kaufmed
Flag of United States of America image

What class(es) (from which namespaces) are you using to submit the query to the database?
Avatar of Sheldon Livingston

ASKER

I'm using ADODB if that is what you mean.  Realize that the only line of code I am changing is the query.
First, I would log into the database server and run the query from there.  Second, I would start with the "SELECT * FROM SOMSAT WHERE fduedate > '2/12/2018'" statement and add each additional clause until I located the one that is causing the error.

-saige-
ASKER CERTIFIED SOLUTION
Avatar of Sheldon Livingston
Sheldon Livingston
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial