• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

ContentValues是错误排序表的字段,为什么以和解决

用户头像
it1352
帮助1

问题说明

早上好每个人;



我正在尝试在android中创建一个数据库类,它已经完成了,我已经成功创建了一个表太。当我想使用ContentValues向表中插入行时,问题出现了,它尝试以不同的顺序从表字段中插入行,这会导致logcat中的错误说:没有这样的表如下:



这些是我的变量:



Good morning every body;

I''m trying to make a database class in android, and it is done, I''ve created a table successfully too. The problem comes when I want to insert rows to the table using ContentValues, it tries to insert the row in different order from the table fields which cuases an error in the logcat saying : no such table as follows:

These are my variables:

private static final String row_ID="RID";
   private static final String row_NAME="NAME";
   private static final String row_EMAIL="EMAIL";
   private static final String row_WEBSITE="WEBSITE";
   private static final String row_TELEPHONE1="PHONE_NUMBER1";
   private static final String row_TELEPHONE2="PHONE_NUMBER2";
   private static final String row_TELEPHONE3="PHONE_NUMBER3";
   private static final String row_TELEPHONE4="PHONE_NUMBER4";
   private static final String row_TELEPHONE5="PHONE_NUMBER5";
   private static final String db_NAME="ContactsDb";
   private static final String tab_NAME="ContactsTab";
   private static final int db_VERSION=2;
   private dbHelper ourHelper;
   private final Context ourContext;
   private SQLiteDatabase ourDatabase;





我的桌子:





My table :

String CREATE_TABLE="CREATE TABLE "   db_NAME   " ("
                          row_ID   " INT PRIMARY KEY AUTOINCREMENT,"
                          row_NAME   " TEXT, "
                          row_EMAIL   " TEXT, "
                          row_WEBSITE   " TEXT, "
                          row_TELEPHONE1   " TEXT, "
                          row_TELEPHONE2   " TEXT, "
                          row_TELEPHONE3   " TEXT, "
                          row_TELEPHONE4   " TEXT, "
                          row_TELEPHONE5   " TEXT);";
    db_name.execSQL(CREATE_TABLE);







使用ContentValues插入行:






Inserting rows using ContentValues :

    public long createEntry(String name, String email, String website, String telephone1, String telephone2, String telephone3, String telephone4, String telephone5)
{
    ContentValues cv = new ContentValues ();

    Log.v("STATUS", "getting input data..");

    cv.put(row_NAME, name);
    cv.put(row_EMAIL, email);
    cv.put(row_WEBSITE, website);       
    cv.put(row_TELEPHONE1, telephone1);
    cv.put(row_TELEPHONE2, telephone2);
    cv.put(row_TELEPHONE3, telephone3);
    cv.put(row_TELEPHONE4, telephone4);
    cv.put(row_TELEPHONE5, telephone5);
    Log.v("STATUS", "got input data, inserting data....");

    return ourDatabase.insert(tab_NAME, null, cv);
}







所以,当我运行这个应用程序时,它会成功完成所有这些,直到它到达ourDatabase.insert(tab_NAME,null,cv);它显示错误:






So, when I run this application it succeeds doing all these until it arrives to ourDatabase.insert(tab_NAME, null, cv); it shows the error:

SQLiteLog            (1) no such table: ContactsTab
SQLiteDatabase       Error inserting Name=Ahlam M. Hussain   PHONE_NUMBER5=
                     PHONE_NUMBER4=   PHONE_NUMBER3=    PHONE_NUMBER2=059999999
                     PHONE_NUMBER1= 09299999    EMAIL=ahlam@ahlam.com  WEBSITE=
SQLiteDatabase       android.database.sqlite.SQLiteException: no such table:
                     ContactsTab (code 1): ,while compiling: INSERT INTO
                     ContactsTab(NAME, PHONE_NUMBER5 PHONE_NUMBER4 PHONE_NUMBER3
                     PHONE_NUMBER2 PHONE_NUMBER1, EMAIL, WEBSITE) VALUES
                     (?,?,?,?,?,?,?,?)





您可以注意到它正在尝试插入行在不同的领域秩序,所以它不承认桌子..



那么该怎么办???我真的很糟糕..



You can notice that it is trying to insert row in different fields orderm so it is not recognizing the table..

So what to do ??? I really got suck of that..

正确答案

#1
你发送给DB的是什么?



那里的值是EWebsite???
What do you sent to the DB?

The value there says "EWebsite" ???
我一直在写数据库名称
db_NAME

而不是创建表语句中的表名

instead of the table name

tab_NAME





感谢每一个人给予帮助..

in the create table statement :)

Thanks for every one gave help..

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhchaegj
系列文章
更多 icon
同类精品
更多 icon
继续加载