Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 没有这样的列:pratik(代码1):编译时:从Insert_表中删除,其中NAME=pratik_Android_Sqlite - Fatal编程技术网

Android 没有这样的列:pratik(代码1):编译时:从Insert_表中删除,其中NAME=pratik

Android 没有这样的列:pratik(代码1):编译时:从Insert_表中删除,其中NAME=pratik,android,sqlite,Android,Sqlite,我正在传递一个要删除的字符串名,但它给了我一个错误,我无法删除该行。有人能告诉我我的代码有什么问题吗?它说没有这样的列我不知道为什么,它说没有这样的列我不知道为什么 package com.example.bipinp.mithun; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.s

我正在传递一个要删除的字符串名,但它给了我一个错误,我无法删除该行。有人能告诉我我的代码有什么问题吗?它说没有这样的列我不知道为什么,它说没有这样的列我不知道为什么

    package com.example.bipinp.mithun;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Bipinp on 2/18/2016.
 */
public class DatabaseHelper extends SQLiteOpenHelper {
    public static final String DATABASE_NAME = "Sales.db";
    public static final String TABLE_NAME1 = "Insert_table";
    public static final String TABLE_NAME2 = "Entry_table";

    public static final String COL_ID = "ID";
    public static final String COL_NAME = "NAME";

    public static final String COL_CUST_NAME = "NAME";
    public static final String COL_CARET = "CARET";
    public static final String COL_AMOUNT = "AMOUNT";
    public static final String COL_AMOUNT_PAID = "AMOUNT_PAID";
    public static final String COL_BALANCE = "BALANCE";

    public DatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, 1);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table " + TABLE_NAME1 + " (ID INTEGER PRIMARY KEY AUTOINCREMENT,NAME TEXT)");
        db.execSQL("create table " + TABLE_NAME2 + " (ID INTEGER PRIMARY KEY AUTOINCREMENT,NAME TEXT,CARET INTEGER,AMOUNT INTEGER,AMOUNT_PAID INTEGER,BALANCE INTEGER,FOREIGN KEY(ID) REFERENCES Insert_table(ID_NAME))");

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS" + TABLE_NAME1);
        db.execSQL("DROP TABLE IF EXISTS" + TABLE_NAME2);
        onCreate(db);

    }

    public boolean deleteRow(String name)
    {   SQLiteDatabase db = this.getWritableDatabase();
        return db.delete(TABLE_NAME1, COL_NAME + "=" + name, null) > 0;
    }

    public boolean insertdata(String name){
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(COL_NAME,name);
        long result = db.insert(TABLE_NAME1,null,contentValues);
        if(result == -1)
            return  false;
        else
            return true;
    }

    public boolean insertdata2(String name,String caret,String amount,String amount_paid,String balance){
        SQLiteDatabase db = this.getWritableDatabase();
        ContentValues contentValues = new ContentValues();
        contentValues.put(COL_CARET,name);
        contentValues.put(COL_CARET,caret);
        contentValues.put(COL_AMOUNT,amount);
        contentValues.put(COL_AMOUNT_PAID,amount_paid);
        contentValues.put(COL_BALANCE,balance);
        long result = db.insert(TABLE_NAME2,null,contentValues);
        if (result == -1)
            return false;
        else
            return true;
    }

    public List<String> getAllLabels(){
        List<String> labels = new ArrayList<String>();

        String selectQuery = " SELECT " + COL_NAME + " FROM " + TABLE_NAME1;
        SQLiteDatabase db = this.getReadableDatabase();
        Cursor cursor = db.rawQuery(selectQuery,null);

        if (cursor.moveToFirst()){
            do { labels.add(cursor.getString(0));
            }while (cursor.moveToNext());
        }
        cursor.close();
        db.close();

        return labels;
    }


}
改变

public boolean deleteRow(String name)
    {   SQLiteDatabase db = this.getWritableDatabase();
        return db.delete(TABLE_NAME1, COL_NAME + "=" + name, null) > 0;
    }


您忘记了名称的引号,这是一个字符串,因此它是必需的

添加删除代码和获取的错误日志我收到此错误02-20 20:07:26.553 12917-12940/com.example.bipinp.mithun W/EGL_仿真:eglSurfaceAttrib未实现02-20:07:26.553 12917-12940/com.example.bipinp.mithun W/OpenGLRenderer:未能在曲面上设置EGL_交换_行为0xdf9cf6c0,error=EGL_SUCCESS 02-20 20:07:28.445 12917-12940/com.example.bipinp.mithun E/Surface:getSlotFromBufferLocked:unknown buffer:0xEEADB2A0该错误看起来不像来自数据库,您能否显示导致该错误的活动代码>
public boolean deleteRow(String name)
    {   SQLiteDatabase db = this.getWritableDatabase();
        return db.delete(TABLE_NAME1, COL_NAME + "= '" + name + "';", null) > 0;
    }