(1)在“ existsUserInformation”附近:语法错误 [英] (1) near "existsUserInformation": syntax error

查看:85
本文介绍了(1)在“ existsUserInformation”附近:语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public class DataBaseClass extends SQLiteOpenHelper {

    public static final String DB_NAME = "USER DATA";
    public static final int DB_VERSION = 1;

    public static final String TABLE_NAME_USERSINFO = "UserInformation";
    public static final String COLUMN_NAME_FIRSTNAME = "FirstNamestring";
    public static final String COLUMN_NAME_LASTNAME = "LastNamestring";
    public static final String COLUMN_NAME_ADD1 = "Add1string";
    public static final String COLUMN_NAME_ADD2 = "Add2string";
    public static final String COLUMN_NAME_SSNFRST ="SSnfirststring";
    public static final String COLUMN_NAME_SSNLST = "SSnlaststring";
    public static final String COLUMN_NAME_MOBNO = "ContactNostring";
    public static final String COLUMN_NAME_EMAILID = "emailidstring";
    public static final String COLUMN_NAME_DOB = "Dateofbirthstring";

    public DataBaseClass(Context context) {
        super(context, DB_NAME, null, DB_VERSION);
        // TODO Auto-generated constructor stub

    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        // TODO Auto-generated method stub
        String sqlQueryToCreateUserInformation = "create table if not exists" + TABLE_NAME_USERSINFO +
                "(" + BaseColumns._ID + "integer primary key autoincrement,"
                + COLUMN_NAME_FIRSTNAME + " text not null,"
                + COLUMN_NAME_LASTNAME + " text not null,"
                + COLUMN_NAME_ADD1 + " text not null,"
                + COLUMN_NAME_ADD2 + " text not null,"
                + COLUMN_NAME_SSNFRST + " text not null,"
                + COLUMN_NAME_SSNLST + " text not null,"
                + COLUMN_NAME_MOBNO + " text not null,"
                + COLUMN_NAME_EMAILID + " text not null,"
                + COLUMN_NAME_DOB + " text not null,"
                + ");";
        db.execSQL(sqlQueryToCreateUserInformation);

    }

    public void insertForm(String FirstNmstring, String LastNmstring, 
            String Add1string ,String Add2string,String SSnfirststring,
            String SSnlaststring, String ContactNostring, String emailidstring, String Dateofbirthstring) {

        String sqlQueryToCreateUserInformation;

        ContentValues cv=new ContentValues();

        cv.put(COLUMN_NAME_FIRSTNAME,FirstNmstring);
        cv.put(COLUMN_NAME_LASTNAME, LastNmstring);
        cv.put(COLUMN_NAME_ADD1, Add1string);
        cv.put(COLUMN_NAME_ADD2, Add2string);
        cv.put(COLUMN_NAME_SSNFRST, SSnfirststring);
        cv.put(COLUMN_NAME_SSNLST, SSnlaststring);
        cv.put(COLUMN_NAME_MOBNO, ContactNostring);
        cv.put(COLUMN_NAME_EMAILID, emailidstring);
        cv.put(COLUMN_NAME_DOB, Dateofbirthstring);

        getWritableDatabase().insert("USER DATA", null, cv);

        }

我正在执行此代码以将数据存储在SQLite数据库中内置Android手机。在执行代码时,我收到一条错误消息,该错误消息是(1)在 existsUserInformation附近:语法错误

I am executing this code to store my data in SQLite database built in Android phones. When I am executing my code, I am getting an error message that is "(1) near "existsUserInformation": syntax error"

请帮我解决这个问题。

推荐答案

您在字符串串联中缺少空格:

You are missing a space in your string concatenation:

"create table if not exists" + TABLE_NAME_USERSINFO

结果为字符串

"create table if not existsUserInformation".

在存在后添加一个空格:

Just add a space after exists:

"create table if not exists " + TABLE_NAME_USERINFO.

语句结尾处还会有一个逗号。

You also have an extra comma at the end of your statement.

这篇关于(1)在“ existsUserInformation”附近:语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆