Problème de requête BDD SQLite
j ai cette methode chequier qui récupère la valeur du champ interdi_cheq (soit 0 ou 1) qui est de type int, le pb c'est que j ai une erreur indiquant que le champ interdiè_cheq n'existe pas alr qui'il existe
voila la methode qui contient la requete
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
public String chequier(String numcpte,String logincheq){
String kk=null;
// bdd.execSQL(" FOREIGN_KEYS PRAGMA = ON ");
Cursor cursor =db.rawQuery(" select " + Database.COMPTE_TABLE_NAME + " . " + Database.COMPTE_CHEQ + " AS interdi_cheq"+","+ Database.COMPTE_TABLE_NAME + " . " + Database.COMPTE_ID + " AS _id" + "from" + CLIENTS_TABLE_NAME +","+ COMPTE_TABLE_NAME +
" where " + Database.COMPTE_TABLE_NAME +"."+ Database.COMPTE_NCP + " = '" + numcpte + "'"
+ " and " + Database.CLIENTS_TABLE_NAME +"."+ Database.CLIENTS_LOGIN + " = '" + logincheq + "'" + " and " + Database.CLIENTS_TABLE_NAME +" . "+ Database.CLIENTS_CLT+ "=" +Database.COMPTE_TABLE_NAME + "."+ Database.COMPTE_CLI,null);
if (cursor!=null){
if (cursor.moveToFirst()){
do
{
kk=cursor.getString(cursor.getColumnIndex("interdi_cheq"));
}while (cursor.moveToNext());
}
}
cursor.close();
return kk;
} |
elle retourne un string QUE je convertis dans mon activité (DemandeChequier)en int puis je teste sa valeur
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
private OnClickListener validerListener = new OnClickListener() {
@Override
public void onClick(View v) {
chaine1 = numcpte.getText().toString();//je recupere le numero de compte pr tester la valeur du champ interdi_cheq correspondant
Database dbUser = new Database (DemandeChequier.this);
dbUser.open();
if((chaine1.equals(""))){
message();
}
try{
if(chaine1.length() > 0)
{
if(dbUser.Auth_compte(chaine1) ) //si la valeur (numero de compte) existe ds la bdd
{
String soldee=dbUser.chequier(chaine1,agec_de_chequier);
int ss=Integer.parseInt(soldee);
if (ss==0)
Toast.makeText(DemandeChequier.this,"Demande eregistrée", Toast.LENGTH_LONG).show();
else
Toast.makeText(DemandeChequier.this,"Demande refusée", Toast.LENGTH_LONG).show();
}else{
Toast.makeText(DemandeChequier.this,"Ce numero de compte n'existe pas", Toast.LENGTH_LONG).show();
}
dbUser.close();
}}
catch(Exception e)
{
Toast.makeText(DemandeChequier.this,e.getMessage(), Toast.LENGTH_LONG).show();
}
dbUser.close();
}}
; |
et en plus qd j insére un compte (statiquement) avec
Code:
1 2 3 4 5
| Compte compte1 = new Compte("9000","courant","20/04/2015",3000,700,1);
clientbBdd.open();
clientbBdd.insertCompte(compte1);
clientbBdd.(); |
le dernier champ c'est "interdi_cheq" je ne sais pas pourquoi j'insére un "1" mais en consultant la bdd je trouve "0"
pouvez vous m'aider svp