-=-
.
.....
  
 
RSS
Direkomendasikan menggunakan brower Opera/Chrome/Firefox. Resolusi minimal 1024x768 | Powered by ____ |
 
  
 
Nikmati Delphi-ID dalam berbagai versi tampilan :
Basic View (LOW Bandwidth)
Default View (Full)
Mobile Edition
Main Menu
..:: onWebTools ::..
..:: onLastPosts ::..
goto Postjumlah komponen maksimal dalam sebuah project(6)
 by d4mnf1y32
 on 21.May at 12:16
goto Posttanya grayscale to biner dengan scanline(1)
 by luckynvic
 on 20.May at 20:44
goto Posttanya looping biner to matriks(1)
 by luckynvic
 on 20.May at 20:10
goto Postsql error:acces denied for user....(2)
 by nasbms
 on 19.May at 16:54
goto Postpemanggilan frame(4)
 by nasbms
 on 19.May at 16:14
goto Posttanya AvLock(0)
 by azuriza
 on 19.May at 11:24
goto PostGet TDBEdit Value Menggunakan LookUp Grid(10)
 by henry_sys
 on 18.May at 11:27
goto Postmenghitung record dalam perulangan(4)
 by idhiel
 on 16.May at 13:53
goto Posttanya ascii(4)
 by mas_kofa
 on 16.May at 12:11
goto PostRawPrint Untuk Delphi XE2(0)
 by adewijaya
 on 15.May at 22:34
goto Postdatabase error..(4)
 by idhiel
 on 15.May at 15:57
goto Postbekasi, pt arila putra mahkota(3)
 by mas_kofa
 on 15.May at 15:37
goto Postbagaimana cara membaca file *.doc dg delphi?(0)
 by ficky
 on 15.May at 06:14
goto Posttanya biner to matriks(13)
 by diandewi
 on 14.May at 20:30

..:: onLast Articles ::..
..:: New Download ::..
Pascal-id.Org
Feeds -  Popular -  Latest
RE: The Longue
8 months, 3 weeks ago
RE: belajar pascal
8 months, 3 weeks ago
RE: The Longue
8 months, 3 weeks ago
RE: belajar pascal
8 months, 3 weeks ago
RE: Perkenalan dan Absen
8 months, 3 weeks ago
RE: Alhamdulillah Buka Puasa Bersama
8 months, 4 weeks ago
RE: تَقَبَّلَ اللهُ مِنَّا وَمِنْكَ - Selamat Hari Raya Idul Fitri
8 months, 4 weeks ago
Lintas Situs
«
free web site stats and visitor tracking

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
adhisyandaOffline
Location:
Post subject: masukin data ke var dari database  PostPosted: 26/Nov/2009 16:11
onIntermediate


Joined: 08-Nov-2009
Posts: 40

Status: Offline
kk,,
aq mu nanya gmn ya caranya masukin data dari database ke variable...
misalnya ada field nama d database..
mu aq masukin ke var yg berbentuk array..
gmn y caranya???
txh b4...
plz help me...
 
 View user's profile Send private message  
Reply with quote Back to top
DelphiExpert
Location:
Post subject: RE: masukin data ke var dari database  PostPosted: 26/Nov/2009 17:51
onMage


Joined: 06-Feb-2006
Posts: 2401

perlu diperjelas lagi var berbentuk array seperti apa yg dimaksud...?
apakah utk menampung value 1 field aja (nama)
atau utk menampung value semua field?

_________________
Dude, if you don't understand the basics and just want to get someone else write the code for you, it means you really shouldn't study computer science. Find a different field.
http://delphiexpert.wordpress.com
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
adhisyandaOffline
Location:
Post subject: RE: masukin data ke var dari database  PostPosted: 27/Nov/2009 16:13
onIntermediate


Joined: 08-Nov-2009
Posts: 40

Status: Offline
misalnya nama var nya nama:array [1..50] of string;
aq mu ngambil datanya dari field nama..
jd smua yg ada di field nama entar aq tampung di var nama...
gtu kk...
 
 View user's profile Send private message  
Reply with quote Back to top
n3o_cybertech
Location: NgAyUkYoKarTo
Post subject: RE: masukin data ke var dari database  PostPosted: 28/Nov/2009 23:30
onProfessional


Joined: 10-Feb-2007
Posts: 993
Location: NgAyUkYoKarTo
code : pascal
  1. var
  2. ArrNama: array of string;
  3. begin
  4. with Query1 do
  5. begin
  6. Close;
  7. SQL.Text('SELECT * FROM adm_pegawai');
  8. Open;
  9. SetLength(ArrNama,RecordCount-1);
  10. while not Eof do
  11. ArrNama[RecNo] := FieldByName('nama').AsString;
  12. end;
  13. end;
Parsed in 0.004 seconds, using GeSHi


kira2 bgitu sih,klo msih error ya coba perbaiki sndiri dlu ya...Very Happy

_________________

Delphi Rock!

Blog : MyBlog | Facebook : Add Me :)
 
 View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger  
Reply with quote Back to top
adhisyandaOffline
Location:
Post subject: RE: masukin data ke var dari database  PostPosted: 29/Nov/2009 09:54
onIntermediate


Joined: 08-Nov-2009
Posts: 40

Status: Offline
kk,,
qo wkt aq run malah form nya g mau keluar sama skali??
awal nya ada error tp dah aq perbaiki...
tp ttp g jln..
conection nya aq pake ado DB nya aq pke mysql


procedure TForm1.FormActivate(Sender: TObject);
var
i:integer;
begin
n:=1;
with ADOQuery1 do
begin
SetLength(Nama,RecordCount-1);
while not Eof do
begin
Nama[RecNo] := FieldByName('user').AsString;
inc(n);
end;
end;

end;


procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
begin
for i:=1 to n do
begin
StringGrid1.Cells[1,i]:=nama[i];
end;
end;


var nama nya aq pake sbg var global.
plz help me kk...
 
 View user's profile Send private message  
Reply with quote Back to top
heriy4nt0Offline
Location:
Post subject: RE: masukin data ke var dari database  PostPosted: 29/Nov/2009 13:15
onKnowledgeable


Joined: 25-Jul-2008
Posts: 145

Status: Offline
di dalam looping :
      Code:
while not eof do
begin
.........
Next;   //---------> tambahkan next di baris terakhir sebelum keluar looping while
end;

n = 1?? ..array dynamic dimulai dari 0 jadi n:=0;
 
 View user's profile Send private message  
Reply with quote Back to top
adhisyandaOffline
Location:
Post subject: RE: masukin data ke var dari database  PostPosted: 29/Nov/2009 13:19
onIntermediate


Joined: 08-Nov-2009
Posts: 40

Status: Offline
malah jd error kk,,,,,
gmn dung???
 
 View user's profile Send private message  
Reply with quote Back to top
adhisyandaOffline
Location:
Post subject: RE: masukin data ke var dari database  PostPosted: 29/Nov/2009 13:26
onIntermediate


Joined: 08-Nov-2009
Posts: 40

Status: Offline
sry doubl post..
error messagenya "raised exception class ...."
plz help me kk expertise....
 
 View user's profile Send private message  
Reply with quote Back to top
heriy4nt0Offline
Location:
Post subject: RE: masukin data ke var dari database  PostPosted: 29/Nov/2009 13:51
onKnowledgeable


Joined: 25-Jul-2008
Posts: 145

Status: Offline
procedure TForm1.FormActivate(Sender: TObject);--------->>gunakan OnShow (jangan OnActive)
var
i:integer;
begin
n:=1;----------------->>seharusnya n=0
with ADOQuery1 do
begin
SetLength(Nama,RecordCount);-->recordcount tidak perlu dikurang 1
while not Eof do
begin
Nama[n] := FieldByName('user').AsString;-->>bukan nama[Recno]
inc(n);
next; --->> tambahkan next
end;
end;

end;


procedure TForm1.Button1Click(Sender: TObject);
var i:integer;
begin
StringGrid.rowcount := n+1;
for i:=0 to n do
begin
StringGrid1.Cells[1,i+1]:=nama[i];
end;
end;
 
 View user's profile Send private message  
Reply with quote Back to top
adhisyandaOffline
Location:
Post subject: RE: masukin data ke var dari database  PostPosted: 29/Nov/2009 14:10
onIntermediate


Joined: 08-Nov-2009
Posts: 40

Status: Offline
msh ttp g bisa kk...
error report nya msh ttp kaya yg td....
Crying or Very sad Sad Crying or Very sad Sad Crying or Very sad
 
 View user's profile Send private message  
Reply with quote Back to top
heriy4nt0Offline
Location:
Post subject: RE: masukin data ke var dari database  PostPosted: 29/Nov/2009 15:56
onKnowledgeable


Joined: 25-Jul-2008
Posts: 145

Status: Offline
di baris dan di procedure mana error nya ?? DEBUG programnya (gunakan Breakpoint dan FCool untuk mengetaui errornya dibagian mana, sy tidak dpt membantu tanpa informasi ini.
 
 View user's profile Send private message  
Reply with quote Back to top
n3o_cybertech
Location: NgAyUkYoKarTo
Post subject: RE: masukin data ke var dari database  PostPosted: 29/Nov/2009 19:44
onProfessional


Joined: 10-Feb-2007
Posts: 993
Location: NgAyUkYoKarTo
code : pascal
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3. arrNama: array of string;
  4. i: integer;
  5. begin
  6. with Q1 do
  7. begin
  8. Close;
  9. SQL.Text := 'SELECT nama FROM anggota';
  10. Open;
  11.  
  12. SetLength(arrNama,Q1.RecordCount);
  13. while not Eof do
  14. begin
  15. arrNama[RecNo - 1] := FieldByName('nama').AsString;
  16. Next;
  17. end;
  18. end;
  19.  
  20. with ListBox1.Items do
  21. begin
  22. Clear;
  23. for i := Low(arrNama) to high(arrNama) do
  24. Add(arrNama[i]);
  25. end;
  26. end;
Parsed in 0.008 seconds, using GeSHi


klo Query itu ada di DataModule,mendingan load DataModule secara runtime aja pas event OnCreate form utama karena form utama secara default akan di-create terlebih dahulu daripada DataModule. Semoga membantu Very Happy

_________________

Delphi Rock!

Blog : MyBlog | Facebook : Add Me :)
 
 View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger  
Reply with quote Back to top
adhisyandaOffline
Location:
Post subject: RE: masukin data ke var dari database  PostPosted: 01/Dec/2009 19:17
onIntermediate


Joined: 08-Nov-2009
Posts: 40

Status: Offline
dah aq akalin kk...
ternyata kesalahnya ada di penggunaan array dinakic nya...
jd aq coba pake array yg statis ternyata jalan..
thx ya atas bantuannya...
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 12 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic





Powered by PNphpBB2 © 2003-2009 The Zafenio Team
Credits


| Register | Lost Password ? |