command クラス : Scalar()メソッド
説明
SQL文を実行します。
構文
instance.Scalar()
引数
無し。
返り値
| クラス | 説明 |
| string | 結果セットの最初の行の最初の列の値。 |
サンプルコード
| 1: | connection cnn = new connection("Data Source=c:\somedirectory\somedatabase.sqlite3;Version=3;"); |
| 2: | cnn.Open(); |
| 3: | // It makes sure of existence of the "sometable". |
| 4: | command cmm = new command("select count(*) from sqlite_master where type='table' and name='sometable';", cnn); |
| 5: | // If it exists, return 1 in string. Otherwise, return 0 in string. |
| 6: | string numStr = cmm.Scalar(); |
| 7: | cmm.Release(); |
| 8: | cnn.Close(); |
| 9: | cnn.Release(); |
注意
返り値が string であることに注意してください。
結果が数値の時は、数値が文字列として戻ります。例 : 1 -> '1' / 1.05 -> '1.05'
結果が文字列の時は、文字列がダブルクォートで囲まれて戻ります。例 : 'Returned string' -> '"Returned string"'
結果がnullの時や評価不能の時は、文字列 'null' が戻ります。
参照リンク
無し。


