2016-09-07 22 views
2

MySQLReaderがレコードを検索し終わったかどうかを確認したい。MySQLReaderが実行されているかどうかを確認するVB.Netを実行中/検索中

これまでのところ、このコードはレコードの検索に役立ちます。

if reader.HasRows then 
    while reader.Read() 
    //codes 
    end while 
else 
//else condition codes 
end if 

実際にReaderが実行を終了したかどうかを知りたいです。 reader.Finished()//**but there's no such thing like this code**のようなものです。誰かがこれを助けることができますか?

答えて

2

reader.Read()は、Readerの読み込みが終了するとfalseを返します。これにより、ループが終了するwhileが発生します。次のようなことができます:

if reader.HasRows then 
    while reader.Read() 
     ''codes 
    end while 
    ''Do whatever it is you wanted to do when the reader is finished. 
else 
    ''else condition codes 
end if 
関連する問題