ContentValues是错误排序表的字段,为什么以和解决
问题说明
早上好每个人;
我正在尝试在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..
正确答案
你发送给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
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
复制文件夹/文件而不修改属性?
it1352 07-15