java.lang.IllegalArgumentException: the bind value at index 1 is null or java.lang.IllegalArgumen


在用SQLiteDatabase查询有两种方法:

      1.  the first :

      {
  1. Cursor cursor = db.query(TABLE_NAME, null,"account=?", new String[]{useraccount}, null, null, null);  
  2. while(cursor.moveToFirst)  
Cursor cursor = db.query(TABLE_NAME, null,"account=?", new String[]{useraccount}, null, null, null);
while(cursor.moveToFirst)
      }

      2.   the second

       {
  1. String existSql = "select * from "+TABLE_NAME+" where account=?";  
  2. Cursor cursor = db.rawQuery(existSql, new String[]{useraccount});  
  3. <pre class="html" name="code">while(cursor.moveToFirst)</pre><br>  
  4. <p></p>  
  5. <pre></pre>  

   


java.lang 
类 IllegalArgumentException
java.lang.Object
  java.lang.Throwable
      java.lang.Exception
          java.lang.RuntimeException
              java.lang.IllegalArgumentException


这个java.lang.IIIegalArgumentException 的解释如下:


public class IllegalArgumentExceptionextends RuntimeException抛出的异 常表明向方法传递了一个不合法或不正确的参数


找到这个问题对应的出现错的行:


  1. Cursor c = db.rawQuery("select * from tablename where cntrct_no=? AND product_code=?",  
  2.                 new String[]{cntrct_no, product_code});  
  3.             while (c.moveToNext()) { }  
Cursor c = db.rawQuery("select * from tablename where cntrct_no=? AND product_code=?",
				new String[]{cntrct_no, product_code});
			while (c.moveToNext()) { }


错误出在:在查询sql数据结果的时候,你是绑定的是第一个,然而第一个出现了null,所以就跑出异常了。



String existSql = "select * from "+TABLE_NAME+" where account=?";
Cursor cursor = db.rawQuery(existSql, new String[]{useraccount});
<div class="dp-highlighter bg_html"><div class="bar"><div class="tools"><strong>[html]</strong> <a target=_blank title="view plain" class="ViewSource" href="http://blog.csdn.net/nobaddd/article/details/7273112#">view plain</a><a target=_blank title="copy" class="CopyToClipboard" href="http://blog.csdn.net/nobaddd/article/details/7273112#">copy</a><a target=_blank title="print" class="PrintSource" href="http://blog.csdn.net/nobaddd/article/details/7273112#">print</a><a target=_blank title="?" class="About" href="http://blog.csdn.net/nobaddd/article/details/7273112#">?</a></div></div><ol class="dp-xml"><li class="alt"><span><span>while(cursor.moveToFirst)  </span></span></li></ol></div><pre class="html" style="display: none;" name="code">while(cursor.moveToFirst)

      因为这次粗心大意..浪费了半天    -_-|||必须记录下来以此为鉴. 

版权声明:本文为博主原创文章,未经博主允许不得转载。

 
    
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值