我要插入到数据库..A形式的价值..two都是整数,一个是string..but我不能够在我的SQLite数据库查看器来查看对此我输入值..我使用以下code:
I want to insert into a database ..a form's value ..two of them are integer and one is string..but i am not able to view in my sqlite database viewer the value which i am entering.. i am using the following code:
SQLiteDatabase myDB= null;
String TableName = "basicdetai";
try{
myDB = this.openOrCreateDatabase("Medical", MODE_PRIVATE, null);
/* Create a Table in the Database. */
myDB.execSQL("CREATE TABLE IF NOT EXISTS "
+ TableName
+ " (order_id INT(4), doc_id INT(4),doc_name VARCHAR );");
/* Insert data to a Table*/
myDB.execSQL("INSERT INTO "
+ TableName
+ "(order_id,doc_id,doc_name)"
+ " VALUES ("+ ordid + ","+ doci + ","+ docnam +");");
// line 10 + " VALUES ("+ a + ","+ b + ","+ docnam +");");
// line 11 +"VALUES (5011,4011,'gupta');");
}
catch(Exception e) {
Log.e("Error", "Error", e);
}
finally {
if (myDB != null)
myDB.close();
}
但是当我在上面code。使用11号线,我可以看到(5011,4011,'古普塔')
通过记录SQLite的浏览器。我执行如下操作到我从形式越来越为整数的字符串值转换
but when i am using line 11 in above code i can see the record (5011,4011,'gupta')
through
sqlite browser.
I am performing following operation to convert the string value which i am getting from form to integer
try {
ordid = Integer.parseInt(orderid.getText().toString());
doci = Integer.parseInt(docid.getText().toString());
// qn = Integer.parseInt(qty.getText().toString());
} catch(NumberFormatException nfe) {
System.out.println("Could not parse " + nfe);
}
PLZ帮助..
Plz help ..
请尝试以下查询...
Please try below query...
db.execSQL("insert into your table name (order_id,doc_id,doc_name)" + "values("ordid+","+doci+","
+ "\"" + docnam + "\"" + ") ;");
上一篇:为什么会这样简单的code导致堆栈溢出异常?堆栈、异常、简单、code
下一篇:JavaScript写在GridView控件rowdeleting事件确认删除写在、控件、事件、JavaScript