问题描述
限时送ChatGPT账号..SQLiteDatabase db = this.getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put(colDeptID, 1);
cv.put(colDeptName, "Sales");
db.insert(deptTable, colDeptID, cv);
cv.put(colDeptID, 2);
cv.put(colDeptName, "IT");
db.insert(deptTable, colDeptID, cv);
db.close();
使用此代码,在输入每一行并收到此错误后,我在括号下得到一个红色下划线:标记("上的语法错误,请删除此标记.
With this code, I am getting a red underline under the parenthesis after put in every line and getting this error: Syntax error on token "(", delete this token.
我也收到一条错误消息:令牌上的语法错误,而是预期的 variableDeclarator.有任何想法吗?我已经尝试了所有我知道的方法,但都没有奏效.
I also get an error that says: Syntax error on tokens, variableDeclarator expected instead. Any ideas? I've tried everything I know to do, and none of it worked.
我也得到关闭"时出现语法错误,此令牌后应有标识符
I also get Syntax error on "close", identifier expected after this token
我从教程中复制并粘贴了这段代码,所有评论都说它有效,但我遇到了很多问题.感谢您如此快速的回复.
I copy and pasted this code from a tutorial and all the comments said it worked, but I've had quite a few problems out of it. Thanks for such quick replies.
推荐答案
仅声明,例如:
SQLiteDatabase db = this.getWritableDatabase();
ContentValues cv = new ContentValues();
可以直接在类声明中.非声明,例如:
can be directly inside a class declaration. Non-declarations, such as:
cv.put(colDeptID, 1);
cv.put(colDeptName, "Sales");
db.insert(deptTable, colDeptID, cv);
必须在方法、构造函数、初始化块或静态初始化块中.在这种情况下,它们可能应该在构造函数或方法中.
must be inside a method, constructor, initializer block, or static initializer block. In this case they should probably be in a constructor or method.
这篇关于令牌上的语法错误,而是预期的 variableDeclarator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论