Solved

DBGrid problem - Please Help

Posted on 1998-10-31
1
143 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
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now