Arsip: Cara Buat Nomor Urut Otomatis Di DBGRID, Sukses

 
user image
more 13 years ago

faridx

Maaf, Mungkin ada yg bisa bantu, saya pakai Delphi7, ZeosDB6.5.1, MySql4.1, Mau Tanya, Cara Buat Nomor Urut Otomatis, pke select? bagai mana? Mau ditampilkan Di DBGRID nya. trimakasih sebelumnya.
user image
more 13 years ago

n3o_cybertech

no.urut apaan??? data??? pake aja ZQuerynya Zeoss, kalo ga salah sih kodenya Zquery1.RecNo ato yang ada kaitannya dengan itu (lupa). oke deh selamat mencoba. ========================================= KEEP SPIRIT OF PROGRAMMING...!!!! =========================================
user image
more 13 years ago

faridx

Ex: Zquery1.SQL:="select nama,umur from tabel" tampil di DBGRID nama umur A 2 G 6 C 7 H 2 ingin jadi seperti ini no nama umur 1 A 2 2 G 6 3 C 7 4 H 2 tapi "no" nya otomatis, langsung tampil di DBGRID gimana caranya? ingin pake Query,perintahnya "select ........???" apa? Yg sesuai dengan saya pakai Delphi7, ZeosDB6.5.1, MySql4.1. Trims
user image
more 13 years ago

nurez

klos aran sy : buat new table tuk nomer1 tsb, yg bisa di set sewaktu2.. then.. pd saat nge save record tambahkan dlm sqLnya (update set no_urut: no_urut + 1); then buat lg tombol new tambhakan atau di gabungin ajha di tombol save klu bisa :) EDno.text:=FormatFloat('00', adoquery1.FieldByName('nomer1').Asinteger); wah msh newbie dh bljr zeos... sy ajha blum nyoba :( tp ini dibyuat di access loh... blum nyoba di mysql.. ihope its wworks...not worst.. :( makasih
user image
more 13 years ago

faridx

Trims nurez... Tp lebih baik Pake AUTO_INCREMENT supaya ga repot, tp pake ini tidak rapih, kalo ada penghapusan di tengah2 jadi tidak menyusun, Maaf, Maksudnya bukan ingin di tabel MySql saya menambahkan angkanya, Tapi di tabel DBGRID nya, jadi ketika saya memanggil data, di DBGRIDnya ada Nomor Urutnya otomatis langsung menyusun, berdasarkan banya recordnya. Harap bantuan nya... Trims.
user image
more 13 years ago

cyber_hecker

kalo gak mau lewat autoinc, gunakan aja cara simple dengan menggunakan calc field. code sederhana :
unit uFMain;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, DB, Grids, DBGrids, MemDS, DBAccess, MyAccess;
type
  TFMain = class(TForm)
    MyConnection1: TMyConnection;
    MyQuery1: TMyQuery;
    MyQuery1id_cust: TStringField;
    MyQuery1nm_cust: TStringField;
    MyQuery1alamat_cust: TStringField;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    MyQuery1no_urut: TIntegerField;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure MyQuery1CalcFields(DataSet: TDataSet);
  private
    { Private declarations }
    pvCount: integer;
  public
    { Public declarations }
  end;
var
  FMain: TFMain;
implementation
{$R *.dfm}
procedure TFMain.Button1Click(Sender: TObject);
begin
  with MyQuery1 do begin
    SQL.Clear;
    SQL.Append('SELECT '+
      'db_delphier.tb_customer.id_cust, '+
      'db_delphier.tb_customer.nm_cust, '+
      'db_delphier.tb_customer.alamat_cust '+
      'FROM '+
      'db_delphier.tb_customer '
    );
    Open;
  end;
end;
procedure TFMain.FormCreate(Sender: TObject);
begin
  pvCount := 0;
end;
procedure TFMain.MyQuery1CalcFields(DataSet: TDataSet);
begin
  pvCount := pvCount + 1;
  MyQuery1['no_urut'] := pvCount;
end;
end.
user image
more 13 years ago

imunk

@faridx tuh dah di jawab langsung ma mas CH, beliau salah satu master di delphi id ini....:)
user image
more 13 years ago

yayaretina

Pokoknya klo Ch dah mulai jawab pertanyaan.. dijamin komplit.. dari snapshot ampe kodingnya.. moga2 ada ratusan CH di forum ini.. hehehehehehhheeee...
user image
more 13 years ago

faridx


unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, ZAbstractRODataset, ZAbstractDataset, ZDataset, ZConnection,
  StdCtrls, Grids, DBGrids;
type
  TForm1 = class(TForm)
    DBGrid1: TDBGrid;
    Button1: TButton;
    ZConnection1: TZConnection;
    DataSource1: TDataSource;
    ZQuery1: TZQuery;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ZQuery1CalcFields(DataSet: TDataSet);
  private
    pvCount: integer;
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
  ZQuery1.Active:=False;
  ZQuery1.SQL.Text:='select nama,umur from tablat1';
  ZQuery1.Active:=True;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
  pvCount:=0;
end;
procedure TForm1.ZQuery1CalcFields(DataSet: TDataSet);
begin
  pvCount := pvCount + 1;
  ZQuery1.>>>??????????<<<:= pvCount;
end;
end.
Thanx banget Master CH, saya ngerti logikanya, tp klo pake Zeos gimana caranya? Master? tolong ga ngerti yang saya tandain >>>??????????<<< saya harus isi scrip apa? trims, Harap bantunanya.
user image
more 13 years ago

faridx

kalo di isi ZQuery1['nomor_urut']:= pvCount; Ga ngefek?? :( gimana ya???
more ...
  • Pages:
  • 1
  • 2
Share to

Random Topic

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