SQL Server 2000 SELECT COUNT(*) Issue

  • Thread starter Thread starter guevara_81
  • Start date Start date
G

guevara_81

Ok. I can't figure this one out, but maybe someone has some experience
with this.


Seperate boxes (1 running SQL Server 2k, 1 app server, both running win
Server 2003). .Net app that connects from app server to SqlServer box,
does a select count(*) from a table, if count == 0, then process
aborts, else process continues.


For the last two wednesdays in a row, at the same time, the process
counts 0 instead of the actual number. I can take the Sql for the
count and run it manually through QA and get back the correct count. I
can take the app down to my dev environment and run it, everything runs
as expected.


The app is able to connect to the DB, but when it runs the select
count(*), then it returns 0. Has anyone ever experienced this
behavior, know what causes it?


TIA
AP
 
Are you sure the process gets a count of 0 and aborts? Maybe there is an
error happening, so it isn't doing what you expect.
 
i'm trapping any error and emailing myself the error.

i wouldn't think this has any bearing on it, but i'm using an
executeScalar

so

try { count = executeScalar}
catch (Exception ex) {
//code to email myself the encountered error
}
finally {//close connections, etc}

and I do not get recieve a message about an error.

The app ends as expected, when there is no data available to process
(count returns 0)
 
If you have no mail do you continue with 0 ? If yes it would be more likely
as mentionned by Marina that you have a problem with the mail system. Check
perhaps the SMTP server for aborted activity ?

Else depending on how critical and how you cen see this count you could put
something else than 0 suhc as -1. You would make sure then if it comes from
SQL SErver (IMO less likely) or if it is caused by an unexpected condition.
 
Extremely doubtful there is an issue with the email, as the application
delivers a receipt of processing at completion. In the event that an
error is caught, after the notification of error is sent, then the
exception is thrown, as to terminate the application.

I have recently (today) included catches for System.DataException,
System.SystemException and System.Exception.

I am after the set of circumstances to be present, that would let an
application connect to the DB, but return an erroneous count, when you
can connect through Query Analyzer, and get the correct count.

Thanks to all for your input.
AP
 
Back
Top