Re: [android-developers] data base insert err !!table record has no column named blood_type
Your column names are wrong. Check your create statement, I reckon "nametext not null" should be "name text not null".
On Wed, Jun 6, 2012 at 10:13 AM, shengJie <b0091309@gmail.com> wrote:
when i insert some data to my table named record ,but it can't be insertit say it has no column named ***i pull out my database--------------------------------------------------------------------------------------------SQLite version 3.7.12.1 2012-05-22 02:45:53Enter ".help" for instructionsEnter SQL statements terminated with a ";"sqlite> .schemaCREATE TABLE android_metadata (locale TEXT);CREATE TABLE record(_id INTEGER PRIMARY KEY AUTOINCREMENT,care_IDtext not null,nametext not null,sexualtext not null,person_idtext not null,blood_typetext not null);------------------------------------------------------------------------------------------------------------------i didn't know where is the problem ?===========================================================================================D/dalvikvm(4241): GC_EXTERNAL_ALLOC freed 44K, 53% free 2546K/5379K, external 1815K/2137K, paused 210msW/KeyCharacterMap(4241): No keyboard for id 0W/KeyCharacterMap(4241): Using default keymap: /system/usr/keychars/qwerty.kcm.binD/dalvikvm(4241): GC_EXTERNAL_ALLOC freed 172K, 50% free 2836K/5639K, external 3087K/3096K, paused 113msI/haiyang:createDB(4241): create table record (_id INTEGER PRIMARY KEY AUTOINCREMENT,care_IDtext not null,nametext not null,sexualtext not null,person_idtext not null,blood_typetext not null);I/Database(4241): sqlite returned: error code = 1, msg = table record has no column named blood_typeE/Database(4241): Error inserting blood_type=a sexual=CC person_id=ss care_ID=ss name=BBE/Database(4241): android.database.sqlite.SQLiteException: table record has no column named blood_type: , while compiling: INSERT INTO record(blood_type, sexual, person_id, care_ID, name) VALUES(?, ?, ?, ?, ?);E/Database(4241): at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)E/Database(4241): at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)E/Database(4241): at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)E/Database(4241): at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)E/Database(4241): at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:41)E/Database(4241): at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1149)E/Database(4241): at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1569)E/Database(4241): at android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1426)E/Database(4241): at com.NursingcareSystem.Care_ALL_intent$3.onClick(Care_ALL_intent.java:306)E/Database(4241): at android.view.View.performClick(View.java:2485)E/Database(4241): at android.view.View$PerformClick.run(View.java:9080)E/Database(4241): at android.os.Handler.handleCallback(Handler.java:587)E/Database(4241): at android.os.Handler.dispatchMessage(Handler.java:92)E/Database(4241): at android.os.Looper.loop(Looper.java:123)E/Database(4241): at android.app.ActivityThread.main(ActivityThread.java:3683)E/Database(4241): at java.lang.reflect.Method.invokeNative(Native Method)E/Database(4241): at java.lang.reflect.Method.invoke(Method.java:507)E/Database(4241): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)E/Database(4241): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)E/Database(4241): at dalvik.system.NativeStart.main(Native Method)===================================================================================my add listeneradd.setOnClickListener(new OnClickListener(){@Overridepublic void onClick(View v) {// TODO Auto-generated method stubContentValues values = new ContentValues();db.beginTransaction();values.put(UserSchema.CARE_ID, "ss");values.put(UserSchema.NAME, "BB");values.put(UserSchema.SEXUAL, "CC");values.put(UserSchema.PERSON_ID,"ss");values.put(UserSchema.BLOOD_TYPE, "a");SQLiteDatabase db = helper.getWritableDatabase();db.insert(UserSchema.TABLE_NAME, null, values);db.setTransactionSuccessful();db.endTransaction();db.close();onCreate(savedInstanceState);}});-----------------------------------------------------------------------------------------------------------------------------------------my database createdpublic void onCreate(SQLiteDatabase db) {// TODO Auto-generated method stubdb.beginTransaction();try{String caredb ="create table record (_id INTEGER PRIMARY KEY AUTOINCREMENT,"+UserSchema.CARE_ID+ "text not null,"+UserSchema.NAME+ "text not null,"+UserSchema.SEXUAL+ "text not null,"+UserSchema.PERSON_ID+ "text not null,"+UserSchema.BLOOD_TYPE+ "text not null);";Log.i("haiyang:createDB", caredb);db.execSQL(caredb);db.setTransactionSuccessful();}catch(Exception e){}finally{db.endTransaction();}}--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home