How to check if result of request to DB is empty?

Suliman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Dec 12 03:24:28 PST 2015


On Saturday, 12 December 2015 at 10:36:12 UTC, drug wrote:
> 12.12.2015 13:28, Suliman пишет:
>> it's seems that next block is execute even if is rs.next() is 
>> false:
>>
>> writeln("rs.next()-->", rs.next());
>> if(!rs.next()) //if user do not in DB
>> {
>> // is execute even if rs.next() is false
>> writeln("Executed, but rs.nst was set to false");
>> }
>>
>> The output:
>>> rs.next()-->false
>>> Executed, but rs.nst was set to false
>>
>> Why?
>>
>>
>
> That's right, because you have `if(!rs.next())`. If you change 
> this to `if(rs.next())` this code block won't be executed.

http://img.ctrlv.in/img/15/12/12/566c03c0657df.png


More information about the Digitalmars-d-learn mailing list