mardi 25 août 2015

[firedac][phys][SQLite] error unique constraint failed: delphi XE Android

i'm Steve.. i'm new on this site...

i have a problem with my android project. i'm using delphi XE to develop this project.

so, i tried to make 1 input form, but when i try it on my android, the error pop up.

like "[firedac][phys][SQLite] error unique constraint failed: "+tablename+"."+fieldname

You can see it on link below :

http://ift.tt/1EfVaG7

and this is my code for "Simpan" button:

procedure TForm1.Button1Click(Sender: TObject);
begin
if ((Edit1.Text='') or (Edit2.Text='')) then
begin
ShowMessage('Data Kosong');
end
else
if (FDQuery1.Locate('kode_kategori',Edit1.Text,[loCaseInsensitive])) then
ShowMessage('Data Sudah Ada')
else
begin
qkategori.Command.CommandKind := skInsert;
qkategori.SQL.Text:='INSERT INTO kategori VALUES
("'+Edit1.Text+'","'+Edit2.Text+'")';
qkategori.Close;
qkategori.ExecSQL();
qkategori.Open;
FDQuery1.Close;
FDQuery1.Open;
end;
end;

as for the table i just had 2 field ("kode_kategori","nama_kategori")

kode_kategori = primary key, varchar(5)
nama_kategori = varchar(30), Not Null

translation my component to english:

simpan = save
kode_kategori = category code
data kosong = there's data still empty
data sudah ada = there's this data already
nama_kategori = category name

and i'm very sorry for my lack in english.. hehe :D

any help will be fine... thanks before...


Update :

the data still recorded, what i need to do is to make the error gone or being excepted...

Aucun commentaire:

Enregistrer un commentaire