Consider the following code:
StringBuilder textResults = new StringBuilder();
using(SqlConnection connection = new SqlConnection(GetEntityConnectionString()))
{
connection.Open();
m.Connection = connection;
SqlDataReader results = m.ExecuteReader();
while (results.Read())
{
textResults.Append(String.Format("{0}", results[0]));
}
}
I used the Activity Monitor in Sql Server Mgmt Studio in the database to verify the exact request sent. Then I copied this query text to the query editor window in SSMS, and the query returned the expected results. However, it is SqlDataReader resultsalways empty, indicating "listing did not get results."
My suspicion is that somehow the results will not return correctly, which makes me think that something is wrong with the code above, and not with the request itself.
Is there anything that could cause this in the code above? Or something that I forgot?
EDIT:
Here is the request specified by the SQLCommand object:
SELECT DISTINCT StandardId,Number
FROM vStandardsAndRequirements
WHERE StandardId IN ('@param1','@param2','@param3')
ORDER BY StandardId
Here is the query that appears in Activity Monitor:
SELECT DISTINCT StandardId,Number
FROM vStandardsAndRequirements
WHERE StandardId IN ('ABC-001-0','ABC-001-0.1','ABC-001-0')
ORDER BY StandardId
The query works against a single view.
, 3 .
SqlDataReader 0 .