私のテーブルと行は次のようになります。
Table : Visit
Column : VisitDate
Value : 634993344000000000
VisitDate 列は Int64 値を保持します (DateTime.Now.Ticks など)
これをデータベースから読み取っている間、SQLite は列が Int64 値かどうかを検出できません。私のコードは;
switch (sqlite3_column_type(statement,i))
{
case SQLITE_INTEGER:
intValue = (int)sqlite3_column_int(statement, i);
colNameChar = (const char *)sqlite3_column_name(statement, i);
colName = [NSString stringWithCString:colNameChar encoding:NSUTF8StringEncoding];
colValue = [NSNumber numberWithInteger: intValue];
break;
case SQLITE_FLOAT:
dblValue = (double)sqlite3_column_double(statement, i);
colNameChar = (const char *)sqlite3_column_name(statement, i);
colName = [NSString stringWithCString:colNameChar encoding:NSUTF8StringEncoding];
colValue = [NSNumber numberWithDouble: dblValue];
break;
case SQLITE_TEXT:
strValue = (const char *)sqlite3_column_text(statement, i);
colNameChar = (const char *)sqlite3_column_name(statement, i);
colName = [NSString stringWithCString:colNameChar encoding:NSUTF8StringEncoding];
colValue = [NSString stringWithCString:strValue encoding:NSUTF8StringEncoding];
break;
case SQLITE_BLOB:
strValue = (const char *)sqlite3_column_value(statement, i);
colNameChar = (const char *)sqlite3_column_name(statement, i);
colName = [NSString stringWithCString:colNameChar encoding:NSUTF8StringEncoding];
colValue = [NSString stringWithCString:strValue encoding:NSUTF8StringEncoding];
break;
case SQLITE_NULL:
strValue = nil;
colNameChar = (const char *)sqlite3_column_name(statement, i);
colName = [NSString stringWithCString:colNameChar encoding:NSUTF8StringEncoding];
colValue = [[NSObject alloc] init];
break;
default:
strValue = (const char *)sqlite3_column_value(statement, i);
colNameChar = (const char *)sqlite3_column_name(statement, i);
colName = [NSString stringWithCString:colNameChar encoding:NSUTF8StringEncoding];
colValue = [NSString stringWithCString:strValue encoding:NSUTF8StringEncoding];
break;
}
デバッガーは SQLITE_INTEGER のケースに入り、ガベージ値 (-2323423 のようなもの) を生成します。どうすれば正しい値を取得できますか?