更新SQLite - 接近"WHERE":语法错误(代码 1 SQLITE_ERROR):



我最近在我的SQLite数据库中添加了一列,因为添加此列是一个按钮,我可以将其中一个数据库列的值设置为";1〃;或";0";现在,当按钮尝试使用updateData(),时,我的应用程序开始崩溃,所以我认为这就是我的问题所在,是在updateData()的代码或语法中

错误:

android.database.sqlite.SQLiteException:near"其中":语法错误(代码1 SQLITE_ERROR(:,编译时:UPDATE my_manager SETlocation_name="blarney stone",location_county='Cork',locationdescription='jj',location_route='1',location_position='2',location_longg='null',location_lat='null',location_url='JJ',location_url2='JJ',location_arl3='JJ',其中location_id="1"在android.database.sqlite.SQLiteConnection.naturePrepareStatement(Native方法(

代码:

void updateData(String id, String row_id, String name, String county, String description, String 
in_route, String position, String lat, String longg, String url, String url2, String url3) {
System.out.println(TABLE_NAME+"; "+row_id +"; "+ name +"; "+ county+"; "+ description+"; " + lat 
+"; "+ longg+"; "+ url +"; "+ url2 +"; "+ url3 +"; ");
SQLiteDatabase db = this.getReadableDatabase();
db.execSQL("UPDATE " + "my_manager" + " SET location_name = "+"'"+ name + "' " + ", " +
"location_county = " + "'"+ county + "'"+ "," +
"location_description = " + "'"+ description +  "'" + "," +
"location_route = " + "'"+ in_route +  "'" + "," +
"location_position = " + "'"+ position +  "'" + "," +
"location_longg = " + "'"+ longg +  "'" + "," +
"location_lat = " + "'"+ lat +  "'" + "," +
"location_url = " + "'"+ url +  "'" + "," +
"location_url2 = " + "'"+ url2 +  "'" + "," +
"location_url3 = " + "'"+ url3 +  "'" + "," + " WHERE location_id = "+"'"+ row_id+"'");

对不起,我的朋友不认为这是坏事,但你能避免太多不必要的事情吗+"如果可能的话。

void updateData("UPDATE my_manager SET location_name = '"+ name + "', " +
"location_county = '"+ county + "', " +
"location_description = '"+ description +  "'," +
"location_route = '"+ in_route +  "', " +
"location_position = '" + position + "', " +
"location_longg = '" + longg + "'," +
"location_lat = '" + lat +  "'," +
"location_url = '" + url +  "', " +
"location_url2 = '"+ url2 +  "', " +
"location_url3 = '"+ url3 +  "' WHERE location_id = '"+ row_id+"'");

相关内容

  • 没有找到相关文章

最新更新