Matur Nuwun Sampun Mampir Mugi-Mugi Saget Dados Ilmu Ingkang Manfaat Fiddunya Wal Akherat

Rabu, 16 Juni 2010

Tambah, Edit, Simpan, Hapus

Pada pemrograman delphi untuk koneksi dapat dilakukkan bermacam-macam cara seperti menggunakan ADO, ODBC, dll. Disini kita akan membahas tentang script yang biasa digunakan untuk tambah, edit, hapus, dan simpan menggunkan TQuery.

Tambah Data

Query2.SQL.Clear;
Query2.SQL.Text:='INSERT INTO tbNama (nama,alamat) values('''+edNama.text+''','''+edAlamat.text+''')';
Query2.ExecSQL;
edNama.Text:='';
edAlamat.Text:='';

Refresh(Query1);

Edit data

Edit3.Text:=Query1.fieldbyname('Nama').AsString;
Edit4.Text:=Query1.fieldbyname('Alamat').AsString;
btSimpan.Enabled:=true;
btEdit.Enabled:=false;

Hapus data

id := query1.fieldbyname('ID').AsString;
query2.SQL.Clear;
Query2.SQL.Add('DELETE FROM tbNama WHERE ID ='+id+'');
Query2.ExecSQL;

Refresh(Query1);

Simpan data

id := query1.fieldbyname('ID').AsString;

query1.SQL.Clear;
Query1.SQL.add('UPDATE tbNama SET Nama='''+Edit3.Text+''',Alamat='''+Edit4.Text+''' WHERE ID='+id+'');
Query1.ExecSQL;

edit3.Text:='';
edit4.Text:='';

refresh(query1);
btEdit.Enabled:=true;
btSimpan.Enabled:=false;

Selamat mencoba semoga bermanfaat..... ^-^. Chayooooo.....




1 komentar:

Anonim mengatakan...

Maam Tae


Silakan Bekomentar.!!!


Semakin banyak berkomentar, semakin banyak backlink, semakin cinta Search Engine terhadap blog anda
:a:
:b:
:c:
:1: :2: :3: :4: :5: :6:
:7: :8: :9: :10: :11: :12:

Posting Komentar

Tinggalkan Pesan

Get cash from your website. Sign up as affiliate.Join 4Shared Now! affiliate program

EARN CASH FROM YOUR SITE

Turn your valuable site visitors into income. Work online and join our free money making partner program. We offer the most commission rate to help maximize your income stream.

Join our money making program absolutely no charge and 100% risk free.

Sign Up...

Mountain a constant stream of money

Our money making system helps you to establish a constant stream of cash, 24 hours a day, 7 days a week, 365 days a year. Allowing you more time to focus on the things you love. You'll even receive money while you sleep!

Start receiving steady affiliate revenue

This money earn program really can make you profit on the same day. Start collecting serious partner income with almost no effort at all. This is a serious revenue opportunity, the first step for you to build a steady, reliable, long-time profitable business.

A constant money generator

Imagine running of a something that never failed to provide you with income-flow. A earning money program so amazingly profitable that you never had to work for a boss ever again!

Lotta Rewards Lotta Rewards