2013-03-19 1 views
0

Я получаю эту ошибку от своего логарифма.У табличного клиента нет столбца с именем height

03-19 08:41:48.174: E/Database(271): Error inserting height=53.0 status=OBESE bmi=38.290850836596654 contact_num=00000000000 address=usa age=21 gender=female weight_client=153.0 full_name=claire 
03-19 08:41:48.174: E/Database(271): android.database.sqlite.SQLiteException: table client has no column named height: , while compiling: INSERT INTO client(height, status, bmi, contact_num, address, age, gender, weight_client, full_name) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?); 

Когда я использую эмулятор, это происходит. Но когда я пытаюсь это сделать на своем устройстве, вставка данных, похоже, не вызывает проблем. Я смущен, почему это происходит. Может кто-нибудь, пожалуйста, объясните мне это?

Кроме того, вот код от моего DBAdapter и от моего ViewClient.class, который может помочь в определении того, где проблема.

код из моего DBAdapter:

public static final String TABLE_NAME = "client"; 
public static final String CLIENT_ID = "client_id"; 
public static final String FULLNAME = "full_name"; 
public static final String GENDER = "gender"; 
public static final String ADDRESS = "address"; 
public static final String AGE = "age"; 
public static final String CONTACT_NUM = "contact_num"; 
public static final String HEIGHT = "height"; 
public static final String WEIGHT = "weight_client"; 
public static final String BMI = "bmi"; 
public static final String STATUS = "status"; 

String sq_clients = "CREATE TABLE " + TABLE_NAME + 
         "(" + CLIENT_ID + " integer primary key autoincrement, " + 
         FULLNAME + " text not null, " + 
         GENDER + " text not null, " + 
         ADDRESS + " text not null, " + 
         AGE + " integer not null, " + 
         CONTACT_NUM + " text not null, " + 
         HEIGHT + " integer not null, " + 
         WEIGHT + " integer not null, " + 
         BMI + " integer not null, " + 
         STATUS + " text not null);"; 

ViewClient.java:

package com.example.********; 

import android.app.Activity; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.Button; 
import android.widget.EditText; 

public class DatabaseViewClient extends Activity { 

    private EditText fullname; 
    private EditText address_client; 
    private EditText age_client; 
    private EditText gender; 
    private EditText contactNum_client; 
    private EditText height_client; 
    private EditText weight_client; 
    private Button btnSaveCustomer; 

    int current_client_id; 
    String current_client_fullname; 
    String current_client_address; 
    String current_client_contactnum; 
    String current_client_height; 
    String current_client_weight; 
    String current_client_gender; 
    int current_client_age; 
    String current_client_bmi, current_client_status; 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.addclient); 

     fullname = (EditText) findViewById(R.id.fullname); 
     gender = (EditText) findViewById(R.id.gender); 
     age_client = (EditText) findViewById(R.id.age_client); 
     address_client = (EditText) findViewById(R.id.address_client); 
     contactNum_client = (EditText) findViewById(R.id.contactNum_client); 
     height_client = (EditText) findViewById(R.id.height_client); 
     weight_client = (EditText) findViewById(R.id.weight_client); 

     btnSaveCustomer = (Button) findViewById(R.id.save); 

     Bundle extras = getIntent().getExtras(); 
     current_client_id = extras.getInt("CLIENT_ID"); 
     current_client_fullname = extras.getString("FULLNAME"); 
     current_client_gender = extras.getString("GENDER"); 
     current_client_age = extras.getInt("AGE"); 
     current_client_address = extras.getString("ADDRESS"); 
     current_client_contactnum = extras.getString("CONTACT_NUM"); 
     current_client_height = extras.getString("HEIGHT"); 
     current_client_weight = extras.getString("WEIGHT"); 
     current_client_bmi = extras.getString("BMI"); 
     current_client_status = extras.getString("STATUS"); 

     fullname.setText(current_client_fullname); 
     gender.setText(current_client_gender); 
     address_client.setText(current_client_address); 
     contactNum_client.setText(current_client_contactnum); 
     height_client.setText(current_client_height); 
     weight_client.setText(current_client_weight); 


     fullname.setKeyListener(null); 
     gender.setKeyListener(null); 
     age_client.setKeyListener(null); 
     address_client.setKeyListener(null); 
     contactNum_client.setKeyListener(null); 
     height_client.setKeyListener(null); 
     weight_client.setKeyListener(null); 

     btnSaveCustomer.setVisibility(View.GONE); 
} 
} 

ответ

0

ВЫСОТА + "числа не равно нуль,"

И you're делать: вставив высоту = 53.0

Так что я предполагаю, что это может быть причиной

UPD - Я вижу, что у вас есть масса как целое и уже не надо проблем, так что должно быть что-то другое, то :)

+0

Я уже удалил часть «не null» в моем запросе, но все же он упоминает ту же проблему. – clairecaceres

+0

Я думаю, что если он работает на устройстве, то ничего не узнать. Эмулятор, как сказано, не лучший инструмент. – Roman

0

Если он работает на устройстве и не на эмуляторе, он работает. Это, вероятно, не то, что вы хотите услышать, но эмулятор, как известно, ошибочный и непоследовательный. У меня были схожие вопросы, когда эмулятор и устройство действуют по-другому - «решение» не должно использовать эмулятор.

По существу, если ваш вопрос соответствует строкам «на эмуляторе X, но на устройстве Y» или просто «почему X не работает на эмуляторе», то скорее всего проблема будет в эмуляторе. В любом случае, нет проблем с адресацией, характерной для эмулятора.

+0

Благодарю вас за ваши ответы и немного поделитесь с вами. Наверное, я сразу почувствовал панику, столкнувшись с этой ошибкой. – clairecaceres

Смежные вопросы