XenKid
XenKid

Reputation: 161

sqlite select record one by one in vb.net

I have this records in the table:

username, password, rights, allowance
admin, asdf, admin, 20
john, qwer, user, 10
peter, zxcv, user, 10

I want to select one record at a time

I used:

for i as integer = 1 to sqliteDataReader.FieldCount
dim ss as string = "select * from xtable where recno()=" & Ctr(i)
...
Next

But it doesn't get 1 record at a time.

Upvotes: 1

Views: 2215

Answers (1)

Tim Lehner
Tim Lehner

Reputation: 15251

It looks like a way to iterate using recno is described here.

I would, however, recommend selecting individual records from a database table by using a primary key or a unique key that you've set rather than a DBMS-specific row numbering scheme. In your case, it would probably also be best to grab all the records you will need in one query and then iterate through that set in your application code, so you don't have to repeatedly connect and select from the database. Perhaps using a DataTable or SqliteDataReader might be more appropriate.

Also, I should point out that you are currently iterating through records by first only getting a count of the columns in your table. I'm not sure if the number of rows of your table is always going to be equal to the number of columns. That would seem odd.

Upvotes: 2

Related Questions