Arsip: Hapus Data di Database Menggunakan Listview Checkbox

 
user image
more 11 years ago

mrajex

Mas mas mo nanya gimna caranya menghapus data yg ada di database? code yg ane buat baru seperti ini...
procedure TForm1.btnHapusClick(Sender: TObject);
var
i :integer;
begin
   i:=0;
   while i<ListView1.Items.Count do
   if ListView1.Items.Item[i].Checked then
   ListView1.Items.Item[i].Delete
   else
   Inc(i);
end;
user image
more 11 years ago

elva_ivana

kira2 begini cara nya (silahkan di betulkan jiga ada yg lbh simpel)

procedure TForm1.btnHapusClick(Sender: TObject);
var
i :integer;
begin
   i:=0;
   while i<ListView1.Items.Count do
   if ListView1.Items.Item[i].Checked then
   sql.close;
   sql.clear;
   sql.add('delete from tabelku where tabelId='+ListView1.Items.Item[i].caption);
   sql.execute;
   else
   Inc(i);
end; 
user image
more 11 years ago

elva_ivana

..ada yg kelewat ...
@elva_ivana: kira2 begini cara nya (silahkan di betulkan jiga ada yg lbh simpel)

procedure TForm1.btnHapusClick(Sender: TObject);
var
i :integer;
begin
   i:=0;
   while i<ListView1.Items.Count do
   if ListView1.Items.Item[i].Checked then
   sql.close;
   sql.clear;
   sql.add('delete from tabelku where tabelId='+ListView1.Items.Item[i].caption);
   sql.execute;
   // else ----> dihapus
   Inc(i);
end; 
user image
more 11 years ago

mrajex

Oke gan makasih....dah beres sekarang :)
user image
more 11 years ago

elva_ivana

Oke... sama-sama
user image
more 11 years ago

willyalves

bingung ya, kok pny ak gak bisa pake adocommand malahan access violation sdgkan kl pake query malah does not support returning multiple dataset
user image
more 11 years ago

elva_ivana

koda yg udah kamu buat seprti apa ??
user image
more 11 years ago

willyalves

gini kak ak hampir sama kodenya,,cm ak pengen delete nya sesuai yg uda kecentang di checkbox jg
if (listview1.Selected <> nil)  then
  begin
  i:=0;
  while i<ListView1.Items.Count do
  if ListView1.Items.Item[i].Checked=true then
  adocommand1.CommandText:='delete from invoice where description ='''+(listview1.items.item[i].checked)+''' and [invoice#]='''+(invoice.Text)+''' ';
  adocommand1.Execute;
  refreshdata;
else inc(i);
  end
ak dah coba ilangin else tp malah program infinite loop, saat pake else malah gak delete apa2 hehe.. mohon bantuan dgn sangat
user image
more 11 years ago

elva_ivana

if (listview1.Selected <> nil)  then
  begin
  i:=0;
  while i<ListView1.Items.Count do
  if ListView1.Items.Item[i].Checked=true then
  adocommand1.CommandText:='delete from invoice '+
'where description ='''+(listview1.items.item[i].caption)+
''' and [invoice#]='''+(invoice.Text)+''' ';
  adocommand1.Execute;
  refreshdata;
else inc(i);
  end
user image
more 11 years ago

suwarno

@elva_ivana:
if (listview1.Selected <> nil)  then
  begin
  i:=0;
  while i<ListView1.Items.Count do
  if ListView1.Items.Item[i].Checked=true then
  adocommand1.CommandText:='delete from invoice '+
'where description ='''+(listview1.items.item[i].caption)+
''' and [invoice#]='''+(invoice.Text)+''' ';
  adocommand1.Execute;
  refreshdata;
else inc(i);
  end
Mas Kalo lewat SMDGRID gmn mas??? Saya koneksiny pake ADO dan MS. ACCES???untuk code program nya sendiri bagaimana.... terima kasih mas, salam kenal aja
more ...
  • Pages:
  • 1
  • 2
Share to

Random Topic

Local Business Directory, Search Engine Submission & SEO Tools FreeWebSubmission.com SonicRun.com