在android系统(插入查询)查询源码 [英] Query for sqlite in android (insert query)

查看:128
本文介绍了在android系统(插入查询)查询源码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要插入到数据库..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 + "\"" + ") ;");

这篇关于在android系统(插入查询)查询源码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆