dbreader class : FieldType(int) method

Description

Returns the type of the specified column.

Syntax

instance.FieldType(int columnIndex)

Arguments

ClassNameDescription
intcolumnIndexColumn index.

Return value

ClassDescription
stringType name.

Sample code

1:

connection cnn = new connection("Data Source=c:\somedirectory\somedatabase.sqlite3;Version=3;");

2:

cnn.Open();

3:

command cmm = new command("select * from sometable where id < 100;", cnn);

4:

dbreader dbr = cmm.Reader(); // Command execution. Returns multi-line results.

5:

while(dbr.Read())

6:

string typename = dbr.FieldType(0); // The type name in the first column.

7:

endwhile

8:

dbr.Release();

9:

cmm.Release();

10:

cnn.Close();

11:

cnn.Release();

Notes

If the column type of the database is "INTEGER" and the value is within the range of int, returns the "int". If the value exceeds the range of the int , returns the "long".

If the column type of the database is "REAL", returns the "real".

If the column type of the database is "TEXT", returns the "string"

If the actual data is "NULL" or unevaluable, returns the "null" regardless of the database column type.

The argument should specify in a 0-based index.

If the column corresponding to the argument does not exist, an exception, UnknownException, will be thrown.

Links for reference

None.

Copyright © Cooker All rights reserved.