android上用sqlite报错,求各位大侠解答

Hi_方建康 2012-03-25 10:19:44

String sql = "UPDATE diary Set weather="+"\""+strWeather+"\""+" where(create_year=" + "\"" + strYear+ "\"" + " and create_month=" + "\"" + strMonth + "\""+ " and create_day=" + "\"" + strDay + "\"" + ")";
db.execSQL(sql);


调试时,出现错误,一直没有弄懂为什么,大家帮忙看看呢。

03-25 13:50:03.713: E/Database(8567): Failure 21 (out of memory) on 0x0 when preparing 'delete from diary where(create_year="2012" and create_month="03" and create_day="25")'.
...全文
187 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
leer168 2012-03-26
  • 打赏
  • 举报
回复
是不是用中文的问题啊?
danielinbiti 2012-03-26
  • 打赏
  • 举报
回复
如果这些字段都是文本的话没问题
Hi_方建康 2012-03-26
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 himi_ 的回复:]

SQL语句是单引号好不好,改成 ' 就对了
UPDATE diary Set weather='晴' where(create_year='2012' and create_month='03' and create_day='25')
[/Quote]
回去试试看看,谢谢你的答复!
himi_ 2012-03-26
  • 打赏
  • 举报
回复
SQL语句是单引号好不好,改成 ' 就对了
UPDATE diary Set weather='晴' where(create_year='2012' and create_month='03' and create_day='25')
Hi_方建康 2012-03-26
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 bear1122ccc 的回复:]

语句写错了。多加了双引号。
String sql = "UPDATE diary Set weather="+"\""+strWeather+"\""+" where(create_year="
String sql = "UPDATE diary Set weather="+strWeather+" where(create_year="
[/Quote]
是要加引号,不然SQL执行会报错。
不加引号情况是以下情况:
update diary Set weather=晴 where...
加引号情况为:
update diary Set weather="晴" where...
第二种才是对的吧。
bear1122ccc 2012-03-26
  • 打赏
  • 举报
回复
语句写错了。多加了双引号。
String sql = "UPDATE diary Set weather="+"\""+strWeather+"\""+" where(create_year="
String sql = "UPDATE diary Set weather="+strWeather+" where(create_year="
Hi_方建康 2012-03-26
  • 打赏
  • 举报
回复
我将查询sql语句放在adb上直接运行,按下键盘回车后,控制台就挂住不往下执行了,目前都还没用找到问题的原因,我只好换另外的方式进行处理了!
Hi_方建康 2012-03-25
  • 打赏
  • 举报
回复
帖子上面的错误不对,错误是下面的情况:
03-25 14:31:23.023: E/AndroidRuntime(10090): android.database.sqlite.SQLiteException: unknown error: UPDATE diary Set weather="晴" where(create_year="2012" and create_month="03" and create_day="25")

80,493

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧