Home Notices Documents Classes Download Others Rice
Classes  >  command  >  Scalar()
command class : Scalar() method

Description

Executes the SQL statement.

Syntax

commandInstance.Scalar()

Arguments

None.

Return value

ClassDescription
int, long, real, strinig, or dbnullThe first column of the first row of the result set.

Sample code

1:

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

2:

cnn.Open();

3:

command cmm = new command("select count(*) from sqlite_master where type='table' and name='sometable';", cnn);

4:

int exists = cmm.Scalar(); // Command execution. Checks the existence of the table.

5:

cmm.Release();

6:

cnn.Close();

7:

cnn.Release();

Notes

Returns the value of the first column in the first row of the result set.

If the return value is an integer, it is returned as long class. If there is not the result set, dbnull is returned.

If the return value is a string, the length limit is 2,033 characters.

Links for reference

None.

Copyright © Rice All rights reserved.