2 hh yt HH_YT 于 2014.12.13 10:32 提问

sqlite execSQL(sql, bindArgs) 第二个参数不自动替换的问题
    public static final String USER_TABLE_NAME = "user";
    public static final String USER_TABLE_FIELD_ID = "id";
    public static final String USER_TABLE_FIELD_PASSWORD = "password";

    public static final String DEVICE_TABLE_NAME = "device";
    public static final String DEVICE_TABLE_FIELD_ADDRESS = "address";
    public static final String DEVICE_TABLE_FIELD_NAME = "name";

    public static final String LASTCONNECT_TABLE_NAME = "lastConnect";
    public static final String LASTCONNECT_TABLE_FIELD_ID = "id";
    public static final String LASTCONNECT_TABLE_FIELD_ADDRESS = "address";

 public void onCreate(SQLiteDatabase db)
    {
        String sqlString = "create table ? (? verchar(50) primary key, ? verchar(50))";
        db.execSQL(sqlString, new Object[]{USER_TABLE_NAME, USER_TABLE_FIELD_ID, USER_TABLE_FIELD_PASSWORD});
        db.execSQL(sqlString, new Object[]{DEVICE_TABLE_NAME, DEVICE_TABLE_FIELD_ADDRESS, DEVICE_TABLE_FIELD_NAME});
        db.execSQL(sqlString, new Object[]{LASTCONNECT_TABLE_NAME, LASTCONNECT_TABLE_FIELD_ID, LASTCONNECT_TABLE_FIELD_ADDRESS});
    }

2个回答

HH_YT
HH_YT   2014.12.13 10:33

HH_YT
HH_YT   2014.12.13 10:34

android.database.sqlite.SQLiteException: near "?": syntax error (code 1): , while compiling: create table ? (? verchar(50) primary key, ? verchar(50))

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!