Take a look at these two questions:
- # 1 from SELECT * my_table Includes (my_column, 'monkey') - # 2 SELECT * my_table where (my_column, 'a OR monkey') - "a" is a noise word
query # 1 when I If I run it in the management studio then it gives 20 rows. # Query # 2 returns the same 20 rows, but I also see the following in the message tab:
information: full-
so far Boring - what I really hope to do.
Now, take a look at the C # snippet:
using (SqlConnection conn = new SqlConnection (...)) {SqlCommand cmd = conn.CreateCommand (); // Setup command object ... conn.Open (); (SqlDataReader dr = cmd.ExecuteReader ()) {if (dr.HasRows) {// Column Colonel is found etc ... ... (dr.Read ()) {// Some useful ...}}}}
When I run this code against query # 1, everything behaves as expected - for every 20 lines there is a "do something useful" section.
When I run, against Query # 2, nothing happens - "Do something useful" section is never reached.
is here now where things get a bit more interesting ...
If I remove the check on "code> HasRows , then everything Expected works - "doing something useful" section hits for each of the 20 rows, even if the query is used.
It looks like HasRows
property is not properly populated if SQL Server generates a message that results are returned and read it ()
Using the method, but the HasRows
property may be false.
Is this a known bug. NET and / or SQL Server, or have I made some clear?
I am using VS2008SP1, .NET3.5SP1 and SQL2008.
Edit: I appreciate that my question is very similar, and it is almost certainly a manifestation of the same issue, but this question is stuck for three months. Has gone, no definitive answer.
I am the original poster of a refined question (lost login) and has never been able to remove it. Finally I put it in bad voodoo, sacrificed cleanliness and went some way
bool readerHasRows = false; While (reader.reader ()) {readerHasRows = true; DoStuffOverAndOver (); } If (readerHASRO) (possibly showing better ordering message then) ();}
What was really strange was that it used to work on an ASPX page and was not in each other, while the code The blocks were stored procedures used almost the same time.
I'm avoiding to say. From now on, RARS;)
Edit - Message Studio on the Problem Process in Management Project in My Project The message also appears in the web. It seems that the problem can be a cause, but why does this happen? Thousands ??
EDIT2 - Confirmation to avoid warning messages, and changed query. Now Hazzer is now true.
Comments
Post a Comment