dbreader class : Receive(int) method

Description

Returns the type and the value of the specified column.

Syntax

instance.Receive(int columnIndex)

Arguments

ClassNameDescription
intcolumnIndexColumn index.

Return value

ClassDescription
pairType and value of the column.

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:

pair value = dbr.Receive(0); // The return value is a pair class.

7:

string typename = value.First; // The First is typename.

8:

if(typename == "int");

9:

int intValue = value.Second; // The Second is actual value.

10:

elseif(typename == "long");

11:

long longValue = value.Second;

12:

elseif(typename == "real");

13:

real realValue = value.Second;

14:

elseif(typename == "null"); // If the value is database-null, the First is "null".

15:

// If the First is "null", the Second is a dummy class. You have to do nothing to the dummy.

16:

endif;

17:

endwhile

18:

dbr.Release();

19:

cmm.Release();

20:

cnn.Close();

21:

cnn.Release();

Notes

The class name of the return value and the actual value are stored in the pair class and returned.

If the column type of the database is "INTEGER" and the value is within the range of int, the First is the "int" and the Second is an instance of int class. If the value exceeds the range of the int , the First is "long" and the Second is an instance of the long class.

If the column type of the database is "REAL", the First is the "real" and the Second is an instance of the real class.

If the column type of the database is "TEXT", the First is the "string" and the Second is an instance of the string class. Unlike the Get(int) and Get(string) method, the string is not enclosed in double quotes.

If the actual data is "NULL" or unevaluable, the First is "null" and the Second is an instance of the dummy class, 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.