Solved

DBGrid problem - Please Help

Posted on 1998-10-31
1
147 Views
Last Modified: 2010-04-06
I'm having trouble getting the contents of a table created at runtime to show in a DBGrid (called EstimateGrid). The table is being created and modified successfully, but not showing at all in the grid. Extract of code follows. Please help. Thanks.

DataSource2 := TDataSource.Create(self);
DataSource2.Dataset := Table;
DataSource2.Enabled :=True;
EstimateGrid.DataSource := DataSource2;
EstimateGrid.Enabled := True;
0
Comment
Question by:cavalry
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 8

Accepted Solution

by:
ZifNab earned 10 total points
ID: 1345170
Hi cavalry,

Did a little test, but everything seems to work.

You 're sure the table is active?

ps. Don't forget to free your create datasource!!!!!

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Grids, DBGrids, Db, DBTables;

type
  TForm1 = class(TForm)
    Table1: TTable;
    DBGrid1: TDBGrid;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    DataSource2 : TDataSource;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
DataSource2 := TDataSource.Create(self);
DataSource2.Dataset := Table1;
DataSource2.Enabled :=True;
DBGrid1.DataSource := DataSource2;
DBGrid1.Enabled := True;
Table1.Open;  <----------- !
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
 DataSource2.Free;
end;

end.

Regards, Zif.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert GUI app into console app for Win32 Env 5 126
tidtcpserver connection lost handle 2 112
Firemonkey webbrowser scrollbars ? 1 57
Browsing a TTreeView in Delphi 5 32
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question