November 13th, 2003, 07:07 PM
ADO.NET vs. Query Analyzer: Inconsistent Results
Can anybody explain the following behaviour?
In SQL Query Analyzer:
EXEC GetStatistics 0, 7, 2004
(1 row of data returned - the correct result)
// SqlConnection connection; // connects successfully
// SqlCommand command; // initialized with the query from above, the appropriate parameters, and the connection
DataSet ds = new DataSet();
SqlDataAdapter adapter = new SqlDataAdapter( command );
int numRows = adapter.Fill( ds );
// numRows == 4
// four rows are returned, when there should only be one.
I've checked and rechecked all the parameters, the query text itself -- the lot -- and I can't work out what's going on.
Can anybody shed some light as to why this may be happenning?
November 17th, 2003, 01:31 PM
Query Analizer and ADO.Net use (by default) different connection settings so e.g. terms like
may return different results with different connection settings (ANSI, ...) because "= NULL" is treated differently.
SELECT * FROM MyTable WHERE SomeColumn = NULL
Can you please post your sql statement?