开发者

Saving data into my Database not possible...App ends

开发者 https://www.devze.com 2023-02-08 17:17 出处:网络
Hey everyone ;) I have a new question again :D I can open my app now and insert the data into the fields, but as soon as i click the save-menu-item it aborts ... i posted the piece of code at the end

Hey everyone ;) I have a new question again :D I can open my app now and insert the data into the fields, but as soon as i click the save-menu-item it aborts ... i posted the piece of code at the end of which i think where the error lies. Hope you can help me ;)

//KFZ-Daten updaten (UPDATE)        
                if(getIntent().hasExtra("id") == true)
                {
                    long l = getIntent().getExtras().getLong("id");
                    myDB.execSQL("UPDATE "+wechsel.MY_DB_TABLE+" SET "+
                            "name = '"+KfzName.getText().toString()+"', "+
                        "model = '"+KfzModel.getText().toString()+"', "+
                        "bemerkungen ='"+KfzBemerkungen.getText().toString()+"', "+
                        "kraftstoffart ='"+i+"', "+
                        "tankinhalt = '"+KfzTankinhalt.getText().toString()+"' "+
                        "WHERE _id = "+l+";"); 
                }
//Neues KFZ in Datenbank speichern (INSERT)             
                else
                {                   
                    myDB.execSQL("INSERT INTO "+wechsel.MY_DB_T开发者_开发百科ABLE+"name,"+ 
                                                                       "model,"+ 
                                                                       "bemerkungen,"+ 
                                                                       "kraftstoffart,"+ 
                                                                       "tankinhalt) "
                            +"VALUES ('"+KfzName.getText().toString()+"',"+
                            "'"+KfzModel.getText().toString()+"',"+
                            "'"+KfzBemerkungen.getText().toString()+"',"+
                            "'"+i+"',"+"'"+
                                               KfzTankinhalt.getText().toString()+"');");
                }
                finish();
                return true;    
            }
            else
            {
                Toast toast = Toast.makeText(this, "Bitte geben Sie einen Namen für das Fahrzeug ein!", 
                                                                   Toast.LENGTH_SHORT);
                toast.show();
            }
        }
        return false;
    }
}


It looks like you are missing an opening paren in the INSERT statement just before the name field:

                myDB.execSQL("INSERT INTO "+wechsel.MY_DB_TABLE+" (name,"+ 
0

精彩评论

暂无评论...
验证码 换一张
取 消