ExecuteReader throws exception for empty result set

39 views
Skip to first unread message

garyala...@gmail.com

unread,
Jan 27, 2015, 11:36:03 AM1/27/15
to npgsq...@googlegroups.com
If you execute the following two statements in C# code:

strDBQuery = "select * from mytable where name = 'gary'";
objDBCommand = new NpgsqlCommand(strDBQuery, objDBConn);
objDBDataReader = objDBCommand.ExecuteReader();

This always throws an exception if the query returns an empty result set. Is there some property of the objDBCommand (the NpgsqlCommand object) that can be tested first to avoid throwing the exception in case the query returns no records?

When running the code in debug mode I am constantly chasing down these annoying exceptions with npgsql.

Shay Rojansky

unread,
Jan 27, 2015, 4:15:37 PM1/27/15
to garyala...@gmail.com, npgsq...@googlegroups.com
Could you please post the exact stack track you are seeing with this code? Is this a "first-chance exception" which gets swallowed/handled internally within Npgsql or an actual exception emitted from Npgsql?


--
You received this message because you are subscribed to the Google Groups "Npgsql Help" group.
To unsubscribe from this group and stop receiving emails from it, send an email to npgsql-help...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/npgsql-help/840cf921-18aa-4778-809d-75392542f57d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages