1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Brisbane, Australia
    Rep Power

    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)

    In ASP.NET:

    // 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?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Bavaria, Germany
    Rep Power
    Query Analizer and ADO.Net use (by default) different connection settings so e.g. terms like
       SELECT * FROM MyTable WHERE SomeColumn = NULL
    may return different results with different connection settings (ANSI, ...) because "= NULL" is treated differently.

    Can you please post your sql statement?

IMN logo majestic logo threadwatch logo seochat tools logo