因为刚学,好多不懂的,请各位指点下,一直读取不出数据,各位老大一定要帮忙呀
- (void)viewDidLoad {
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory=[paths objectAtIndex:0];
NSString *path=[documentsDirectory stringByAppendingPathComponent:@"2011"];//数据库名为2011
sqlite3 *database;
sqlite3_open([path UTF8String],&database);
sqlite3_stmt *stmt;
const char *sql="select * from content_digital where id='683382'";
sqlite3_prepare_v2(database,sql, -1,&stmt,NULL);
sqlite3_step(stmt);
NSString *Cmmmm=sqlite3_column_text(stmt, 4);//读取一个字段,用alert显示出来
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"hello"
message:Cmmmm
delegate:self
cancelButtonTitle:@"ok"
otherButtonTitles:nil];
[alert show];
[alert release];
sqlite3_finalize(stmt);
sqlite3_close(database);
[super viewDidLoad];
}
- (void)viewDidLoad {
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory=[paths objectAtIndex:0];
NSString *path=[documentsDirectory stringByAppendingPathComponent:@"2011"];//数据库名为2011
sqlite3 *database;
sqlite3_open([path UTF8String],&database);
sqlite3_stmt *stmt;
const char *sql="select * from content_digital where id='683382'";
sqlite3_prepare_v2(database,sql, -1,&stmt,NULL);
sqlite3_step(stmt);
NSString *Cmmmm=sqlite3_column_text(stmt, 4);//读取一个字段,用alert显示出来
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"hello"
message:Cmmmm
delegate:self
cancelButtonTitle:@"ok"
otherButtonTitles:nil];
[alert show];
[alert release];
sqlite3_finalize(stmt);
sqlite3_close(database);
[super viewDidLoad];
}
解决方案 »
- ipad上如何下载文件到本地并打开,即文件管理(开发)
- iphone http网络编程,在某些联通3G下连不上服务器,socket返回码为2(未知错误)
- iphone开发时,如何编译自己的libsqlite.dylib
- iOS开发中有关自动释放对象的疑惑
- 关于框架问题,有没有牛人来看看
- iOS常驻后台开发
- 如何在xcode测试手机网页?
- 请问下IOS怎样监听屏幕解锁
- asihttprequest在release下请求不到数据,debug下可以,求解
- cocoapods启动失败:rror: RPC failed; curl 56 SSLRead() return error -9845
- 往php的服务器发送“username”并接收返回的数据
- 在开启ARC的情况下,抛出EXC_BAD_ACCESS,各位路过的请进来!!!
NSString *path = [[NSBundle mainBundle] pathForResource:@"2011" ofType:@"db"];