2014-09-11 56 views
0

我仍然有这个错误在Android! 我读了许多解决方案,但他们是没有帮助的.. 的错误是:没有这样的列:星:,编译时:SELECT COUNT(*)为总从tblf其中recId> 1名=星没有这样的列错误

什么是错的?我该如何解决它?

private void useRawQuery3() { 
    // TODO Auto-generated method stub 
    String[] args = {"1","Star"} ; 
    String mySQL = " select count(*) AS Total from tblf" 
    + " where recId>" + args[0] + " and name=" + args[1] ; 
    Cursor c1 = db.rawQuery(mySQL, null) ; 
    int index = c1.getColumnIndex("Total") ; 
    c1.moveToFirst() ; 
    int theTotal = c1.getInt(index) ; 
    Toast.makeText(this, " Total3="+theTotal, Toast.LENGTH_LONG).show() ; 
} 
+0

从手机中清除您的应用程序数据。然后重启你的应用程序 – SerCna 2014-09-11 07:35:33

回答

0

试试这个:

select count(*) AS Total from tblf where recId>1 and name='Star' 

含义:

String mySQL = " select count(*) AS Total from tblf" 
    + " where recId>" + args[0] + " and name='" + args[1] + "'" ; 
+0

但我应该使用这种方式.. 哪里是我的方式错了? – 2014-09-11 07:35:20

+0

你的星星 – alpinescrambler 2014-09-11 07:36:05

+0

之前和之后没有单一的报价..它的工作.. 这些句子写什么规则? 的意思是像空格,引号等? – 2014-09-11 07:48:35

0

您对数据库更改将被应用在从设备或模拟器你清晰的数据。所以:

  1. 从您的设备清除您的应用程序的数据。
  2. 重新启动您的应用程序。
+0

我每次运行应用程序时都会清除它。 – 2014-09-11 07:50:30