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 <[email protected]> wrote: > when i insert some data to my table named record ,but it can't be insert > it say it has no column named *** > i pull out my database > > -------------------------------------------------------------------------------------------- > SQLite version 3.7.12.1 2012-05-22 02:45:53 > Enter ".help" for instructions > Enter SQL statements terminated with a ";" > sqlite> .schema > CREATE TABLE android_metadata (locale TEXT); > CREATE TABLE record(_id INTEGER PRIMARY KEY AUTOINCREMENT,care_IDtext not > null,n > ametext not null,sexualtext not null,person_idtext not null,blood_typetext > not n > ull); > > ------------------------------------------------------------------------------------------------------------------ > > i didn't know where is the problem ? > > =========================================================================================== > D/dalvikvm(4241): GC_EXTERNAL_ALLOC freed 44K, 53% free 2546K/5379K, > external 1815K/2137K, paused 210ms > W/KeyCharacterMap(4241): No keyboard for id 0 > W/KeyCharacterMap(4241): Using default keymap: > /system/usr/keychars/qwerty.kcm.bin > D/dalvikvm(4241): GC_EXTERNAL_ALLOC freed 172K, 50% free 2836K/5639K, > external 3087K/3096K, paused 113ms > I/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_type > E/Database(4241): Error inserting blood_type=a sexual=CC person_id=ss > care_ID=ss name=BB > E/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 listener > > add.setOnClickListener(new OnClickListener(){ > > @Override > public void onClick(View v) { > // TODO Auto-generated method stub > ContentValues 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 created > > public void onCreate(SQLiteDatabase db) { > // TODO Auto-generated method stub > db.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 [email protected] > To unsubscribe from this group, send email to > [email protected] > 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

