Well, in theory anyway, your query worked. What you got back in the ExecuteScalar method is a dataset with two result sets. The first being a 1 row, 1 column table that returned the number of rows affected, 1. The second set, which ExecuteScalar always ignores, contained a 1 row, 1 column table with the value 0 in it. This is the actuall restult of your query. To fix this, make sure you include "SET NOCOUNT ON" in your SQL batch:
string mySqlStatement = @"SET NOCOUNT ON;SELECT COUNT(column) FROM table WHERE condition;SET NOCOUNT OFF";
If your executing a stored procedure to return the code, put the NOCOUNT statements in the procedure, not your code. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome -- modified at 0:33 Thursday 5th January, 2006