利用alertView 插入数据都数据库

-(void)addItemToList

{

UIAlertView *alter=[[UIAlertViewalloc]initWithTitle:@"ADD"message:@"please       input"delegate:selfcancelButtonTitle:@"cancel"otherButtonTitles:@"sure", nil];

alter.alertViewStyle=UIAlertViewStylePlainTextInput;

[alter show];

}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

{

NSString* chooseTitle = [alertView buttonTitleAtIndex:buttonIndex];

if([chooseTitle isEqualToString:@"cancel"])

{

return;

}

else{

NSString *str=[[alertView textFieldAtIndex:0] text];

if (str.length == 0) {

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"

message:@"请输入name"

delegate:nil

cancelButtonTitle:@"好"

otherButtonTitles:nil];

[alert show];

return;

}

//数据库插入

//调用封装好的数据库插入函数

if ([dbexecuteUpdate:@"INSERT INTO ClassList(ClassName) VALUES(?)",str])

{

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"

message:@"插入数据成功"

delegate:nil

cancelButtonTitle:@"好"

otherButtonTitles:nil];

[alert show];

[self.classNameItems removeAllObjects];

//从ClassList表取得数据

FMResultSet *classInfo=[dbexecuteQuery:@"SELECT ClassName FROM ClassList"];

while ([classInfo next]) {

[self.classNameItems addObject:[classInfo stringForColumn:@"ClassName"]];

}

[self.tableViewList reloadData];

}

else {

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"

message:@"插入数据失败"

delegate:nil

cancelButtonTitle:@"好"

otherButtonTitles:nil];

[alert show];

}

}

}

最新文章

  1. 开源Word读写组件DocX 的深入研究和问题总结
  2. [译]用AngularJS构建大型ASP.NET单页应用(一)
  3. 分享记录我的Linux系统入门学习经验
  4. Android之Inflate()方法用途
  5. JS Math 类库介绍
  6. linux驱动程序之电源管理之regulator机制流程 (1)
  7. 提取DLL类库代码
  8. Wamp集成环境安装
  9. 自制IPsec_vpn综合实验
  10. C#保留小数位数的方法
  11. Java基础---Java---IO流-----对象的序列化、管道流、RandomAccessFile、数据类型的流对象DataStream、ByteArrayStream
  12. python的re模块详解
  13. Centos 7.3 安装Grafana 6.0
  14. sublime test3 乱码问题的解决
  15. Retrofit2
  16. Eclipse代码注释模板-code template
  17. 生成.eps文件方法
  18. 201621123037 《Java程序设计》第1周学习总结
  19. C语言实现链表
  20. Python中sorted函数的用法(转)

热门文章

  1. 用GitHub Pages搭了个静态博客
  2. Mybatis 总结
  3. 【转载】在HTML中插入swf文件(转)
  4. 类js效果
  5. Sqlserver 2008清除数据库日志
  6. xcode添加快捷代码块
  7. PHP之session与cookie
  8. JAVA图片验证码
  9. squid 2.7 配置与安装
  10. Lintcode 75.寻找峰值