DATASOURCA TIKLA VE DATASET AYARINI ADODATASET1 YAP
ADODATASET1IN CONNECTIONINIDA ADOCONNECTION1 YAP
BUTTON VE GRID EKLE
KODLAR BU :
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage,
cxEdit, DB, cxDBData, Menus, cxLookAndFeelPainters, StdCtrls, cxButtons,
cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGridCustomTableView,
cxGridTableView, cxGridDBTableView, cxGrid, ADODB, Grids, DBGrids;
type
TForm1 = class(TForm)
ADODataSet1: TADODataSet;
ADOConnection1: TADOConnection;
DataSource1: TDataSource;
cxGrid1DBTableView1: TcxGridDBTableView;
cxGrid1Level1: TcxGridLevel;
cxGrid1: TcxGrid;
cxButton1: TcxButton;
procedure cxButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.cxButton1Click(Sender: TObject);
var
dbf_folder : string;
begin
dbf_folder:='C:\Users\JJJ\Downloads\Compressed';//set your dbf folder location here
ADOConnection1.LoginPrompt:=false;
ADOConnection1.ConnectionString:=Format('Provider=Microsoft.JET.OLEDB.4.0;Data Source=%s;Extended Properties=dBase IV;',[dbf_folder]);
try
ADOConnection1.Connected:=True;
ADODataSet1.CommandText:='Select * from SSS.dbf'; //make your SQL query using the name of the dbf file
ADODataSet1.Open;
while not ADODataSet1.eof do
begin
//do your stuff here
//ADODataSet1.FieldByName('').AsString
ADODataSet1.Next;
end;
except
on E : Exception do
ShowMessage(E.Message);
end;
cxGrid1DBTableView1.BeginUpdate;
cxGrid1DBTableView1.ClearItems;
cxGrid1DBTableView1.DataController.CreateAllItems;
cxGrid1DBTableView1.EndUpdate;
cxGrid1DBTableView1.Columns[0].Summary.FooterKind:=skCount;
cxGrid1DBTableView1.ApplyBestFit();
end;
end.
No comments:
Post a Comment