Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Puzzling situation - same code - different results

$
0
0

Hi everybody,

I am having a very strange situation.

I have a complex class written by my colleague in C# application. I have another class that has a method calling an instance of that class and a Windows Form application that we use for testing. I also have a test project with tests.

So, when I call test method in the test project, it works OK and test passes.

When I debug this application and use the Windows Form that calls the method which in turn calls that class, I'm getting 0 rows.

The code being executed is the following:

 protected Boolean ProcessDataTable(SqlCommand toSqlCommand)
        {
            using (SqlDataReader sqlDataReader = toSqlCommand.ExecuteReader())
            {
                table = new DataTable();
                if (sqlDataReader.HasRows)
                    table.Load(sqlDataReader);
            }
            return true;
        }

When I use tests project, the DataReader.HasRows returns true and all is well. When I debug the application to run that Windows Form, the HasRows returns false for the exactly the same command and parameter.

Now, I thought I'll try to use SQL Profiler and verify that I am using the database I think I am using (although I am 100% sure I am using the same DB). I'm running Standard T-SQL trace, but unfortunately it doesn't show anything, so I am wondering if I need to add some extra events?

How can I figure out why in one case that command returns rows and in another it does not? The row is indeed present in that table. I am running against remote developer's server.

Thanks in advance.


For every expert, there is an equal and opposite expert. - Becker's Law


My blog


My TechNet articles



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>