SQLite ADO.NET and ExecuteScalar ()

The SQLite ADO.Net documentation (sqlite.phxsoftware.com) for the ExecuteScalar () query method reads: "Run the command and return the first column of the first row of the result set (if any) or null if there is no result set returned." I created a table:

create table users ( id integer primary key, name text )

And executed the queue using ExecuteScalar ():

select ( id ) from users where name = @name

But, it’s very strange - I can’t drop the retur value to 'int', only to 'long'! Why is it that the "id" field is defined as an "integer" in the database, and not "bigint"?

+3
source share
2 answers

, SQLite "INTEGER PRIMARY KEYS" , longs (64- ). :

SQLite 64- , . integer "rowid". - , B-Tree, SQLite . . rowid , "ROWID", "OID" "ROWID".

INTEGER PRIMARY KEY, "" , ROWID. SQLite, rowid -NULL . , , BLOB, NULL.

INTEGER PRIMARY KEY - 64- ROWID.

SQLite .

, , , , Convert, 32 . , 32- .

+5

SQLite, , , 32 :

Convert.ToInt32(...)
+2

Source: https://habr.com/ru/post/1724145/


All Articles