将文本视图中的数据插入SQL表时遇到问题。这是我编写的代码:
代码示例:
if (competencies_title.equals( "Genetic Competencies")) {
databaseHelperCompetencies.insertCompetenciesData(loginName, answerName1, answerName2, answerName3, answerName4, competencies_title, recommendedmodule, studentcomments);
Bundle bundle = new Bundle();
loginName = login_name.getText().toString();
recommendedmodule = recommendedModules.getText().toString();
studentcomments = comments.getText().toString();
bundle.putString("name", loginName);
Intent intent = new Intent(Competencies.this, CompetenciesSuccessful.class);
bundle.putString("description", "You have answered all questions for Genetic Competencies");
intent.putExtra("answer1", answerName1);
intent.putExtra("answer2", answerName2);
intent.putExtra("answer3", answerName3);
intent.putExtra("answer4", answerName4);
intent.putExtra("recommendedModules", recommendedmodule);
intent.putExtra("comments", studentcomments);
intent.putExtras(bundle);
startActivity(intent);
}
if (competencies_title.equals("Technical Competencies")) {
databaseHelperCompetencies.insertCompetenciesData(loginName, answerName1, answerName2, answerName3, answerName4, competencies_title, recommendedmodule, studentcomments);
Bundle bundle = new Bundle();
loginName = login_name.getText().toString();
recommendedmodule = recommendedModules.getText().toString();
studentcomments = comments.getText().toString();
bundle.putString("name", loginName);
Intent intent = new Intent(Competencies.this, CompetenciesSuccessful.class);
bundle.putString("description", "You have answered all questions for Technical Competencies");
intent.putExtra("answer1", answerName1);
intent.putExtra("answer2", answerName2);
intent.putExtra("answer3", answerName3);
intent.putExtra("answer4", answerName4);
intent.putExtra("recommendedModules", recommendedmodule);
intent.putExtra("comments", studentcomments);
intent.putExtras(bundle);
startActivity(intent);
}
答案 0 :(得分:0)
您在登录名中输入了值,但在此之前您要插入值,因此会出现错误
if (competencies_title.equals( "Genetic Competencies")) {
Bundle bundle = new Bundle();
loginName = login_name.getText().toString();
recommendedmodule = recommendedModules.getText().toString();
studentcomments = comments.getText().toString();
bundle.putString("name", loginName);
databaseHelperCompetencies.insertCompetenciesData(loginName, answerName1, answerName2, answerName3, answerName4, competencies_title, recommendedmodule, studentcomments);
Intent intent = new Intent(Competencies.this, CompetenciesSuccessful.class);
bundle.putString("description", "You have answered all questions for Genetic Competencies");
intent.putExtra("answer1", answerName1);
intent.putExtra("answer2", answerName2);
intent.putExtra("answer3", answerName3);
intent.putExtra("answer4", answerName4);
intent.putExtra("recommendedModules", recommendedmodule);
intent.putExtra("comments", studentcomments);
intent.putExtras(bundle);
startActivity(intent);
}
if (competencies_title.equals("Technical Competencies")) {
Bundle bundle = new Bundle();
loginName = login_name.getText().toString();
recommendedmodule = recommendedModules.getText().toString();
studentcomments = comments.getText().toString();
bundle.putString("name", loginName);
databaseHelperCompetencies.insertCompetenciesData(loginName, answerName1, answerName2, answerName3, answerName4, competencies_title, recommendedmodule, studentcomments);
Intent intent = new Intent(Competencies.this, CompetenciesSuccessful.class);
bundle.putString("description", "You have answered all questions for Technical Competencies");
intent.putExtra("answer1", answerName1);
intent.putExtra("answer2", answerName2);
intent.putExtra("answer3", answerName3);
intent.putExtra("answer4", answerName4);
intent.putExtra("recommendedModules", recommendedmodule);
intent.putExtra("comments", studentcomments);
intent.putExtras(bundle);
startActivity(intent);
}