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

Vadim Lopatin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Dec 12 04:14:30 PST 2015


On Saturday, 12 December 2015 at 12:06:21 UTC, Suliman wrote:
> On Saturday, 12 December 2015 at 11:53:51 UTC, Suliman wrote:
>> On Saturday, 12 December 2015 at 11:31:18 UTC, Suliman wrote:
>>> Oh sorry! I used wrong host! All ok!
>>
>> Yes, there was issue with host name, but it's do not solve 
>> problem. Second DB have same fields and I still getting false 
>> instead moving into while loop
>
> It's look like it do `next` step before return something.
> So if in DB 1 value it will work like:
> do step
> if no value after it --> return false
> if yes --> return true
>
> but I need any way to check if first value in DB is exists. Any 
> suggestion?

If you expect to have single or zero rows in result, use
if (rs.next()) {
             dbuser = rs.getString(1);
             dbpassword = rs.getString(2);
             writeln(dbuser);
} else {
             writeln("user not found");
}



More information about the Digitalmars-d-learn mailing list