9/06/2009

Back-Up Database Access Dengan Delphi



Welcome ......!!!

Ketemu Lagi Dengan Salah Satu Tips Aku Untuk Memback-up Database Access dengan Delphi.
Delphi Memberikan Bahasa Pemrograman Yang high Level ( Artinya Sangat Mudah Dipahami ) Sehingga membuat User Seperti Aku Mudah Mengelola Databasenya.
Seperti Database Accesss Sendiri Dibuat dari Pabrikan Microsoft, Sehingga Sangat Friendly dengan Kita yang Sudah terbiasa Windows. MS. Access Dapat Dibuat Secara stand Alone Ataupun Dalam Jaringan.
Tetapi Kebanyakan Database Ms.Access Dibuat Dengan stand Alone ( sistem Informasi yang Berdiri Sendiri / Tanpa Terelasi Dengan Sistem Aplikasi Lain.

Okkey Langsung Aj Ke TKP...

procedure TForm3.buka1Click(Sender: TObject);
var namadatabase : widestring;
begin
if application.MessageBox('Membuka database lain akan menutup koneksi'+#13+
'dengan database sekarang. Harap simpan semua pekerjaan.'+#13+
'Anda yakin bermaksud membuka database lain ?','Perhatian',

mb_yesno + mb_iconinformation) =IDYES then
begin
closeallform;
if opendialog.Execute then
begin

namadatabase := opendialog.FileName;
modul.connect.Connected := false;
modul.connect.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source='+ namadatabase+';'+
'Mode=Share Deny None;Extended Properties="";Persist Security Info=False;Jet OLEDB:System database="";'+
'Jet OLEDB:Registry Path="";Jet OLEDB:Database Password="";Jet OLEDB:Engine Type=5;'+
'Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;'+
'Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";'+
'Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;'+
'Jet OLEDB:Don''t Copy Locale on Compact=False;'+
'Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False';
modul.connect.Connected := true;

modul.ADOlogin.Active:=true;
modul.ADOTableDaftar.Active:=true;
modul.ADOTablePenatar.Active:=true;
modul.ADOheader.Active:=true;
modul.ADOQuery1.Active:=true;
modul.ADOTablemikro.Active:=true;
modul.ADOTableanngota.Active:=true;
Form7.ADOQuery1.Active:=true;
Form7.ADOQuery2.Active:=true;
Form12.ADOQuery1.Active:=true;
Form20.ADOQuery1.Active:=true;


// if opendatabase = true then showmessage('berhasil') else showmessage('gagal');
if not(bukadatabase = false) then
begin
application.MessageBox('Database berhasil dibuka :) ','Information',
mb_ok + mb_iconinformation);
Form3.StatusBar1.Panels.Items[0].Text := 'SISTEM INFORMASI PENDAFTARAN - '+opendialog.FileName;

end
else
begin
application.MessageBox('Database gagal dibuka :(','Information',
mb_ok + mb_iconerror);

tutup;
modul.connect.Connected := false;
modul.connect.ConnectionString :='';
modul.connect.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source='+ extractfilepath(application.ExeName)+'\data.mdb;'+
'Mode=Share Deny None;Extended Properties="";Persist Security Info=False;Jet OLEDB:System database="";'+
'Jet OLEDB:Registry Path="";Jet OLEDB:Database Password="";Jet OLEDB:Engine Type=5;'+
'Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;'+
'Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";'+
'Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;'+

'Jet OLEDB:Don''t Copy Locale on Compact=False;'+
'Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False';

modul.connect.Connected := true;
modul.ADOlogin.Active:=true;
modul.ADOTableDaftar.Active:=true;
modul.ADOTablePenatar.Active:=true;
modul.ADOheader.Active:=true;
modul.ADOQuery1.Active:=true;
modul.ADOTablemikro.Active:=true;
modul.ADOTableanngota.Active:=true;
Form7.ADOQuery1.Active:=true;
Form7.ADOQuery2.Active:=true;
Form20.ADOQuery1.Active:=true;
Form28.ADOQuery2.Active:=true;

end;
end;
end;
end;


Tips Masukan Source Code Diatas Kedalam Button Ataupun MainMenu. Sehingga Source Diatas Dapat Ter-ekssekusi.....!!!!!!!
Kesimpulan.... : Simple Aj... Database MS. Access Diatas hanya Dicopy-paste Dalam Nama File Yang Baru. Sehingga Data-data Yang telah tersimpan telah tercopy Semunya.

Okkey Segitu Saja Tulisan Saya Mengenai Delphi, sampai Ketemu Lagi Dalam Kasus Selanjutnya. KEEP Spirit....!!!!